package com.sync.mobileapp;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.AsyncTask;
import android.preference.PreferenceManager;
import android.util.Log;
import com.sync.mobileapp.NativeApiHelper;
import com.sync.mobileapp.Singleton.CameraUploadOrganizer.CameraUploadOrganizer;
import com.sync.mobileapp.Singleton.OfflineManager.FolderOfflineManagerFactory;
import com.sync.mobileapp.interfaces.NativeCallback;
import com.sync.mobileapp.models.CachedPathItems;
import com.sync.mobileapp.models.WebPath;
import com.sync.mobileapp.utils.Thumbnail;
import com.sync.mobileapp.utils.UploadUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.concurrent.atomic.AtomicInteger;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: /tmp/jadx-12339765468568164262.dex */
public class NativeApi extends NativeApiHelper {
public static final int BTYPE_LOCALONLY = 0;
public static final int BTYPE_THUMB1 = 4;
public static final int BTYPE_THUMB2 = 8;
public static int GALLERY_PID = -2;
public static int ORDER_BY_DATE = 2;
public static int ORDER_DESCEND = 32768;
public static String PSEUDO_VERSION = "";
private static final String TAG = "NativeApi";
private static int WATCH_INTERVAL_SEC = 60;
public static final int WHERE_DEFAULT_GALLERY = 2;
public static final int WHERE_DEFAULT_LIST = 0;
public static final int WHERE_DIR_ONLY = 16;
public static final int WHERE_FILE_ONLY = 32;
public static final int WHERE_HAS_THUMB1 = 1;
public static final int WHERE_HAS_THUMB2 = 2;
public static final int WHERE_HAS_THUMB2_OR_IMG_EXT = 8;
public static final int WHERE_SHOW_DELETED = 4;
public static int ORDER_BY_NAME = 1;
public static int ORDER_FOLDERS_FIRST = 131072;
public static int ORDER_NOCASE = 65536;
public static int ORDER_DEFAULT = (ORDER_BY_NAME | ORDER_FOLDERS_FIRST) | ORDER_NOCASE;
static {
System.loadLibrary("syncus");
}
public static String debugCall(JSONObject jSONObject) throws JSONException {
return call(jSONObject, null).toString();
}
public static synchronized JSONObject init(Context context, InitMode initMode, String str) throws JSONException {
synchronized (NativeApi.class) {
if (IS_INIT) {
return new JSONObject().put("errcode", 0);
}
APP_CONTEXT = context.getApplicationContext();
FolderOfflineManagerFactory.getInstance().setAppContext(context);
AssetManager assets = context.getResources().getAssets();
File dir = context.getDir(str, 0);
File file = new File(context.getExternalFilesDir(null), str);
File file2 = new File(context.getExternalCacheDir(), str);
File filesDir = context.getFilesDir();
boolean z = true;
for (File file3 : Arrays.asList(dir, file, filesDir)) {
if (!file3.isDirectory() && !file3.mkdir()) {
log("mkdirs " + file3 + " failed");
JSONObject jSONObject = new JSONObject();
return jSONObject.put("errdesc", "mkdir '" + file3 + "' failed").put("errcode", 1);
}
}
PSEUDO_VERSION = "3.8.13.10";
for (String str2 : Arrays.asList("stats.db", "cfg.db", "cacert.pem", "state.db")) {
if (!copyAssetToDir(str2, assets, dir)) {
log("failed to copy asset " + str2 + " to " + dir);
JSONObject jSONObject2 = new JSONObject();
return jSONObject2.put("errdesc", "failed to copy " + str2 + " to " + dir).put("errcode", 1);
}
}
JSONObject call = call(new JSONObject().put("action", "init").put("overrideversion", PSEUDO_VERSION).put("homedir", dir.toString()).put("docdir", file.toString()).put("offlinecache", file2.toString()).put("cachedir", filesDir.toString()), null);
if (call.getInt("errcode") != 0) {
z = false;
}
IS_INIT = z;
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(APP_CONTEXT);
Boolean valueOf = Boolean.valueOf(defaultSharedPreferences.getBoolean("pref_app_organized_cameraupload", false));
Boolean valueOf2 = Boolean.valueOf(defaultSharedPreferences.getBoolean("pref_app_cameraupload_enable", false));
if (valueOf2.booleanValue() && valueOf.booleanValue()) {
CameraUploadOrganizer.getInstance().organizeCameraUploadFolder();
} else if (valueOf2.booleanValue() && !valueOf.booleanValue()) {
CameraUploadOrganizer.getInstance().unorganizeCameraUploadFolder();
}
return call;
}
}
public static Context getContext() {
return APP_CONTEXT;
}
public static synchronized JSONObject init(Context context, InitMode initMode) throws JSONException {
JSONObject init;
synchronized (NativeApi.class) {
init = init(context, initMode, "default");
}
return init;
}
public static boolean isWifi(Context context) {
NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.getType() == 1;
}
public static JSONObject abortRefreshPaths() throws JSONException {
return call("abortRefreshPaths", null);
}
public static synchronized JSONObject refreshPaths(long j, NativeCallback nativeCallback) throws JSONException {
JSONObject spawnThread;
synchronized (NativeApi.class) {
spawnThread = spawnThread(NativeApiHelper.ThreadedNativeCall.REFRESH_PATHS, new JSONObject().put("action", "refreshPaths").put("pid", j).put("maxiter", 100).put("onlyifolderthan", 0), nativeCallback);
}
return spawnThread;
}
public static synchronized JSONObject clearcache(NativeCallback nativeCallback) throws JSONException {
JSONObject spawnThread;
synchronized (NativeApi.class) {
spawnThread = spawnThread(NativeApiHelper.ThreadedNativeCall.REFRESH_PATHS, new JSONObject().put("action", "clearcache"), nativeCallback);
}
return spawnThread;
}
public static synchronized JSONObject clearoldcache() throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call("clearoldcache", null);
}
return call;
}
public static synchronized JSONObject clearallofflines(NativeCallback nativeCallback) throws JSONException {
JSONObject spawnThread;
synchronized (NativeApi.class) {
spawnThread = spawnThread(NativeApiHelper.ThreadedNativeCall.REFRESH_PATHS, new JSONObject().put("action", "clearallofflines"), nativeCallback);
}
return spawnThread;
}
public static synchronized JSONObject getoffline(long j) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "getofflinefile").put("syncid", j), null);
}
return call;
}
public static synchronized JSONObject getofflineDir() throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "getofflineDir"), null);
}
return call;
}
public static synchronized JSONObject createOffline(long j) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "createOfflinePath").put("syncid", j), null);
}
return call;
}
public static synchronized JSONObject deleteFreeAccount(JSONObject jSONObject) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "deleteFreeAccount").put("cmdname", "acctcancel").put("cmdin", jSONObject), null);
}
return call;
}
public static synchronized JSONObject fileproviderDownloadURL(long j) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "fileproviderDownloadURL").put("syncid", j), null);
}
return call;
}
public static synchronized JSONObject canDownload(long j) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "filecandownload").put("syncid", j), null);
}
return call;
}
public static synchronized JSONObject getOfflineFilesInDir(long j) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "getAllOfflinesInDir").put("needupdate", 0).put("dirsyncid", j), null);
}
return call;
}
public static synchronized JSONObject getDirOfflinePathBySyncid(long j, long j2) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "getOfflineInDirBySyncid").put("syncid", j2).put("dirsyncid", j), null);
}
return call;
}
public static synchronized JSONObject fileproviderIsLatest(long j, String str) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "fileproviderIsLatest").put("syncid", j).put("filepath", str), null);
}
return call;
}
public static synchronized JSONObject offlineFileSetMtime(long j, String str) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "offlineFileSetMtime").put("syncid", j).put("filepath", str), null);
}
return call;
}
public static synchronized JSONObject getOfflineFiles() throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "getOfflines").put("needupdate", 0), null);
}
return call;
}
public static synchronized JSONObject getCachedPath(long j) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "getCachedPath").put("syncid", j), null);
}
return call;
}
public static synchronized JSONObject getCachePath() throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "getcachepath"), null);
}
return call;
}
public static synchronized JSONObject getDirOfflinePath(long j, boolean z) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "getOfflinePathIndir").put("syncid", j).put("create", z), null);
}
return call;
}
public static synchronized JSONObject publinkDecryptFile(String str, String str2, String str3, String str4) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "publinkdecryptfile").put("encdatakey", str).put("sharekeyb64", str4).put("cryptedpath", str2).put("outpath", str3), null);
}
return call;
}
public static synchronized JSONObject fileproviderDecryptFile(long j, String str, String str2) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "fileproviderdecryptfile").put("syncid", j).put("cryptedpath", str).put("outpath", str2), null);
}
return call;
}
public static synchronized JSONObject fileproviderDecryptFileWithCallback(long j, String str, String str2, NativeCallback nativeCallback) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "fileproviderdecryptfilewithcb").put("syncid", j).put("cryptedpath", str).put("outpath", str2), nativeCallback);
}
return call;
}
public static JSONObject multiUploadInfo(long j, String str, String str2, String str3, String str4) throws JSONException {
JSONObject thumbParams = getThumbParams();
return call(new JSONObject().put("action", "multichunkUploadinfo").put("pid", j).put("oripath", str).put("payloadpath", str2).put("label", str3).put("thumb1", str4).put("thumb2", Thumbnail.make(str, thumbParams.getInt("thumb2size"), thumbParams.getInt("thumb2size"), false, thumbParams.getInt("thumb2quality"))), null);
}
public static synchronized JSONObject isProvisionedRefresh() throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call("fileproviderisProvisioned", null);
}
return call;
}
public static synchronized JSONObject multichunkPutInfo() throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "multichunkUploadPutUrl"), null);
}
return call;
}
public static synchronized JSONObject createOfflineDir(long j) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "createOfflineDir").put("syncid", j), null);
}
return call;
}
public static synchronized JSONObject recordOfflineDigest(String str) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "recordOfflineDigest").put("offlinepath", str), null);
}
return call;
}
public static synchronized JSONObject getOutDatedOfflineFiles() throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "getOutdatedOfflineFiles"), null);
}
return call;
}
public static synchronized JSONObject getRemovedOfflineFiles() throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "getRemovedOfflineFiles"), null);
}
return call;
}
public static synchronized JSONObject rewindLastHistid(int i) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "dumpquickRewind").put("rewindvalue", i), null);
}
return call;
}
public static synchronized JSONObject getAncestorid(long j) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "getAncestorid").put("syncid", j), null);
}
return call;
}
public static synchronized JSONObject zeroIsvault() throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "zeroIsVault"), null);
}
return call;
}
public static synchronized JSONObject getNewAddedOfflineFiles(long j) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "getNewAddedOfflineFiles").put("pid", j), null);
}
return call;
}
public static synchronized JSONObject setAllOfflineInactiveByPid(long j) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "setallofflineInactiveByPid").put("pid", j), null);
}
return call;
}
public static synchronized JSONObject setAllOfflineInactive() throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "setallofflineInactive"), null);
}
return call;
}
public static synchronized JSONObject insertOfflineFile(long j) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "insertoffline").put("syncid", j), null);
}
return call;
}
public static JSONObject getCfg() throws JSONException {
return call("getCfg", null);
}
public static JSONObject refreshCfgWait() throws JSONException {
return call("refreshCfg", null);
}
public static JSONObject refreshCfg(NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.REFRESH_CONF, new JSONObject().put("action", "refreshCfg"), nativeCallback);
}
public static JSONObject getThumbParams() throws JSONException {
return call("getThumbParams", null);
}
public static JSONObject watchListing(long j, long j2, long j3, long j4, long j5, long j6, NativeCallback nativeCallback) throws JSONException {
log("watch listing callled: " + j5);
WATCHED_PID = j;
WATCHED_WHEREFLAGS = j2;
WATCHED_ORDERFLAGS = j3;
WATCHED_THUMBTYPE = j4;
WATCHED_NUM_ABOVE = j5;
WATCHED_NUM_BELOW = j6;
WATCHER_CB = nativeCallback;
return new JSONObject().put("errcode", 0);
}
public static void unwatchAll() {
WATCHER_CB = null;
WATCHED_PID = 0L;
}
public static synchronized void spawnBackgroundDownloadThread(NativeCallback nativeCallback) {
synchronized (NativeApi.class) {
if (BG_DOWNLOAD_THREAD == null) {
BG_DOWNLOAD_THREAD = new Thread((Runnable) new 1());
BG_DOWNLOAD_THREAD.start();
}
BG_DOWNLOAD_CB = nativeCallback;
}
}
public static synchronized void spawnBackgroundUploadThread(NativeCallback nativeCallback) {
synchronized (NativeApi.class) {
if (BG_UPLOAD_THREAD == null) {
BG_UPLOAD_THREAD = new Thread((Runnable) new 2());
BG_UPLOAD_THREAD.start();
}
BG_UPLOAD_CB = nativeCallback;
}
}
public static synchronized void spawnBackgroundAutoUploadThread(NativeCallback nativeCallback) {
synchronized (NativeApi.class) {
if (BG_AUTOUPLOAD_THREAD == null) {
BG_AUTOUPLOAD_THREAD = new Thread((Runnable) new 3());
BG_AUTOUPLOAD_THREAD.start();
} else {
SyncApplication.logwrite(TAG, "wake up camera upload");
wakeAutoUpload();
}
BG_AUTOUPLOAD_CB = nativeCallback;
}
}
public static synchronized void pauseBackgroundAutoUploadThread(boolean z) {
synchronized (NativeApi.class) {
}
}
public static synchronized JSONObject nudgeWatcherThread() throws JSONException {
JSONObject put;
synchronized (NativeApi.class) {
wakeWatcher();
put = new JSONObject().put("errcode", 0);
}
return put;
}
public static synchronized void spawnWatcherThread() {
synchronized (NativeApi.class) {
if (BG_WATCHER_THREAD == null) {
BG_WATCHER_THREAD = new Thread((Runnable) new 4());
BG_WATCHER_THREAD.start();
}
}
}
public static synchronized void setWatcherInterval(int i) {
synchronized (NativeApi.class) {
WATCH_INTERVAL_SEC = i;
Log.d(TAG, "Changing watcherinterval to " + i + " now " + WATCH_INTERVAL_SEC);
}
}
public static void clearPathCache(long j, long j2, long j3) {
if (PATH_ITEMS_CACHE == null) {
PATH_ITEMS_CACHE = new Hashtable(100);
}
String str = j + ":" + j2 + ":" + j3;
if (PATH_ITEMS_CACHE.get(str) != null) {
CachedPathItems cachedPathItems = (CachedPathItems) PATH_ITEMS_CACHE.get(str);
cachedPathItems.items.clear();
cachedPathItems.indexes.clear();
cachedPathItems.isloaded = false;
}
}
public static void clearPathCacheBySyncID(long j) {
if (PATH_ITEMS_CACHE == null) {
PATH_ITEMS_CACHE = new Hashtable(100);
}
String valueOf = String.valueOf(j);
for (String str : PATH_ITEMS_CACHE.keySet()) {
if (str.startsWith(valueOf)) {
CachedPathItems cachedPathItems = (CachedPathItems) PATH_ITEMS_CACHE.get(str);
cachedPathItems.items.clear();
cachedPathItems.indexes.clear();
cachedPathItems.isloaded = false;
}
}
}
public static JSONObject preloadListing(long j, long j2, long j3) throws JSONException {
if (PATH_ITEMS_CACHE == null) {
PATH_ITEMS_CACHE = new Hashtable(100);
}
String str = j + ":" + j2 + ":" + j3;
if (PATH_ITEMS_CACHE.get(str) == null) {
Log.d(TAG, "preloadlisting empty cache");
PATH_ITEMS_CACHE.put(str, new CachedPathItems());
}
JSONObject call = call(new JSONObject().put("action", "preloadListing").put("pid", j).put("orderflags", j3).put("whereflags", j2), null);
loadAllItemsInCache(j, j2, j3);
return call;
}
public static boolean isCacheLoaded(long j, long j2, long j3) {
if (PATH_ITEMS_CACHE == null) {
PATH_ITEMS_CACHE = new Hashtable(100);
}
String str = j + ":" + j2 + ":" + j3;
if (PATH_ITEMS_CACHE.get(str) == null) {
PATH_ITEMS_CACHE.put(str, new CachedPathItems());
return false;
}
return ((CachedPathItems) PATH_ITEMS_CACHE.get(str)).isloaded;
}
public static int getPathIndex(long j, long j2, long j3, long j4, boolean z) {
String str = j + ":" + j3 + ":" + j4;
if (PATH_ITEMS_CACHE == null || PATH_ITEMS_CACHE.get(str) == null) {
return -1;
}
CachedPathItems cachedPathItems = (CachedPathItems) PATH_ITEMS_CACHE.get(str);
if (cachedPathItems.isloaded && !cachedPathItems.isloading && cachedPathItems.indexes.containsKey(Long.valueOf(j2))) {
return ((Integer) cachedPathItems.indexes.get(Long.valueOf(j2))).intValue();
}
return -1;
}
public static JSONObject numPathItems(long j, long j2, long j3) throws JSONException {
return call(new JSONObject().put("action", "numPathItems").put("pid", j).put("orderflags", j3).put("whereflags", j2), null);
}
public static ArrayList<WebPath> getItemsInDir(long j, long j2, long j3) throws JSONException {
JSONArray jSONArray = call(new JSONObject().put("action", "getItemsInDir").put("pid", j).put("orderflags", j3).put("whereflags", j2), null).getJSONArray("range");
ArrayList<WebPath> arrayList = new ArrayList<>();
for (int i = 0; i < jSONArray.length(); i++) {
arrayList.add(new WebPath(jSONArray.getJSONObject(i)));
}
return arrayList;
}
private static void loadAllItemsInCache(long j, long j2, long j3) throws JSONException {
String str = j + ":" + j2 + ":" + j3;
Log.d(TAG, "calling loadallitems start loading");
if (PATH_ITEMS_CACHE == null) {
PATH_ITEMS_CACHE = new Hashtable(100);
}
if (PATH_ITEMS_CACHE.get(str) == null) {
PATH_ITEMS_CACHE.put(str, new CachedPathItems());
}
CachedPathItems cachedPathItems = (CachedPathItems) PATH_ITEMS_CACHE.get(str);
JSONObject call = call(new JSONObject().put("action", "getPathItem").put("pid", j).put("idx", cachedPathItems.curidx).put("numbefore", 200).put("numafter", 200).put("whereflags", j2).put("orderflags", j3), null);
HashMap hashMap = new HashMap();
HashMap hashMap2 = new HashMap();
JSONArray jSONArray = call.getJSONArray("range");
for (int i = 0; i < jSONArray.length(); i++) {
JSONObject jSONObject = jSONArray.getJSONObject(i);
jSONObject.put("errcode", 0);
jSONObject.put("servedFromCache", true);
int i2 = jSONObject.getInt("index");
WebPath webPath = new WebPath(jSONObject);
hashMap.put(Integer.valueOf(i2), webPath);
hashMap2.put(webPath.getSyncId(), Integer.valueOf(i2));
}
cachedPathItems.items = hashMap;
cachedPathItems.indexes = hashMap2;
cachedPathItems.isloaded = true;
}
public static JSONObject searchKeywordInSync(String str) throws JSONException {
return call(new JSONObject().put("action", "searchFileName").put("keyword", str), null);
}
public static JSONObject dumpmobile(Long l) throws JSONException {
return call(new JSONObject().put("action", "mobiledump").put("pid", l), null);
}
public static JSONObject removeOfflineFile(long j) throws JSONException {
return call(new JSONObject().put("action", "removeoffline").put("syncid", j), null);
}
public static WebPath getPathItem(long j, long j2, long j3, long j4) throws JSONException {
System.nanoTime();
if (SCROLLING_IN_PROGRESS_COUNTER == null) {
SCROLLING_IN_PROGRESS_COUNTER = new AtomicInteger(0);
}
String str = j + ":" + j3 + ":" + j4;
if (PATH_ITEMS_CACHE == null) {
PATH_ITEMS_CACHE = new Hashtable(100);
}
CachedPathItems cachedPathItems = (CachedPathItems) PATH_ITEMS_CACHE.get(str);
if (PATH_ITEMS_CACHE.get(str) == null) {
PATH_ITEMS_CACHE.put(str, new CachedPathItems());
cachedPathItems = (CachedPathItems) PATH_ITEMS_CACHE.get(str);
}
CachedPathItems cachedPathItems2 = cachedPathItems;
int i = (int) j2;
cachedPathItems2.curidx = i;
WebPath webPath = (WebPath) cachedPathItems2.items.get(Integer.valueOf(i));
if (webPath != null) {
if (!cachedPathItems2.isloading && cachedPathItems2.items.get(Integer.valueOf(i + 100)) == null) {
cachedPathItems2.isloading = true;
AsyncTask.execute((Runnable) new 5(j, j2, j3, j4));
}
return webPath;
}
Log.e(TAG, "Cached item is returning null");
cachedPathItems2.curidx = i;
fetchPathItems(j, cachedPathItems2.curidx, j3, j4, 50, 50);
WebPath webPath2 = (WebPath) cachedPathItems2.items.get(Integer.valueOf(i));
System.nanoTime();
return webPath2;
}
public static void fetchPathItems(long j, int i, long j2, long j3, int i2, int i3) throws JSONException {
String str = j + ":" + j2 + ":" + j3;
if (PATH_ITEMS_CACHE == null) {
PATH_ITEMS_CACHE = new Hashtable(100);
}
CachedPathItems cachedPathItems = (CachedPathItems) PATH_ITEMS_CACHE.get(str);
if (PATH_ITEMS_CACHE.get(str) == null) {
PATH_ITEMS_CACHE.put(str, new CachedPathItems());
cachedPathItems = (CachedPathItems) PATH_ITEMS_CACHE.get(str);
}
CachedPathItems cachedPathItems2 = cachedPathItems;
if (i > ((int) numPathItems(j, j2, j3).getLong("count")) || i < 0) {
cachedPathItems2.isloading = false;
return;
}
JSONArray jSONArray = call(new JSONObject().put("action", "getPathItem").put("pid", j).put("idx", i).put("numbefore", i2).put("numafter", i3).put("whereflags", j2).put("orderflags", j3), null).getJSONArray("range");
for (int i4 = 0; i4 < jSONArray.length(); i4++) {
JSONObject jSONObject = jSONArray.getJSONObject(i4);
jSONObject.put("errcode", 0);
jSONObject.put("servedFromCache", true);
int i5 = jSONObject.getInt("index");
WebPath webPath = new WebPath(jSONObject);
cachedPathItems2.items.put(Integer.valueOf(i5), webPath);
cachedPathItems2.indexes.put(webPath.getSyncId(), Integer.valueOf(i5));
}
cachedPathItems2.isloading = false;
}
public static JSONObject getThumbPath(long j) throws JSONException {
return call(new JSONObject().put("action", "getthumbpath").put("syncid", j), null);
}
public static JSONObject getPathIndex(long j, long j2, long j3, long j4) throws JSONException {
return call(new JSONObject().put("action", "getPathIndex").put("pid", j).put("syncid", j2).put("whereflags", j3).put("orderflags", j4), null);
}
public static JSONObject fileproviderDelete(long j, long j2) throws JSONException {
return call(new JSONObject().put("action", "newfileproviderdelete").put("pid", j).put("syncid", j2), null);
}
public static JSONObject fileproviderRefreshPath(long j) throws JSONException {
return call(new JSONObject().put("action", "fileproviderRefreshPaths").put("pid", j).put("onlyifolderthan", 0).put("maxiter", 100), null);
}
public static JSONObject refreshpathForce(long j) throws JSONException {
return call(new JSONObject().put("action", "refreshpathForce").put("pid", j).put("maxiter", 100), null);
}
public static JSONObject getThumbnailDownloadInput(JSONArray jSONArray, long j) throws JSONException {
return call(new JSONObject().put("action", "fetchThumbGetInput").put("thumb1", j).put("listofsyncid", jSONArray), null);
}
public static JSONObject refreshpathHasChanges(long j) throws JSONException {
return call(new JSONObject().put("action", "refreshpathsCheckChange").put("pid", j).put("onlyifolderthan", 0).put("maxiter", 100), null);
}
public static JSONObject eventCheckAvailable(long j) throws JSONException {
return call(new JSONObject().put("action", "eventCheckAvailable").put("syncid", j), null);
}
public static JSONObject fileprovidergetpathinfo(long j) throws JSONException {
return call(new JSONObject().put("action", "getPathInfo").put("syncid", j).put("provider", 1), null);
}
public static JSONObject eventsFetchThumbs(JSONArray jSONArray) throws JSONException {
return call(new JSONObject().put("action", "eventGetThumb").put("listofsyncid", jSONArray).put("provider", 1), null);
}
public static boolean eventCheckAvailable(long j, long j2) throws JSONException {
if (Integer.valueOf(fileproviderRefreshPath(j2).getInt("errcode")).intValue() != 0) {
SyncApplication.logwrite(TAG, "Failed to make network call to check file exists, using db info.");
}
return call(new JSONObject().put("action", "eventCheckAvailable").put("syncid", j), null).getInt("available") != 0;
}
public static boolean offlineCheckAvailable(long j) throws JSONException {
return call(new JSONObject().put("action", "eventCheckAvailable").put("syncid", j), null).getInt("available") != 0;
}
public static void dumpquickhistid() throws JSONException {
call(new JSONObject().put("action", "printdumpquickhistid"), null);
}
public static JSONObject dumpquickinput() throws JSONException {
return call(new JSONObject().put("action", "dumpquickinput"), null);
}
public static JSONObject dumpquickprocess(JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "dumpquickprocess").put("response", jSONObject), null);
}
public static boolean fileCheckAvailable(long j) throws JSONException {
return call(new JSONObject().put("action", "eventCheckAvailable").put("syncid", j), null).getInt("available") != 0;
}
public static JSONObject changePassword(String str, NativeCallback nativeCallback) throws JSONException {
return call(new JSONObject().put("action", "passwordchange").put("newpass", str).put("currentpass", "dummy"), nativeCallback);
}
public static JSONObject getPathInfo(long j) throws JSONException {
return call(new JSONObject().put("action", "getPathInfo").put("syncid", j), null);
}
public static JSONObject concurrencyTest(long j, long j2) throws JSONException {
return call(new JSONObject().put("action", "concurrencyTest").put("maxiter", j).put("pausemilli", j2), null);
}
public static JSONObject getPopularFiles() throws JSONException {
return call(new JSONObject().put("action", "getPopularFiles"), null);
}
public static JSONObject setLastUsedDate(long j) throws JSONException {
return call(new JSONObject().put("action", "setLastusedtime").put("syncid", j), null);
}
public static synchronized JSONObject uploadNow(String str, String str2, long j, NativeCallback nativeCallback) throws JSONException {
JSONObject spawnThread;
synchronized (NativeApi.class) {
spawnThread = spawnThread(NativeApiHelper.ThreadedNativeCall.UPLOAD_NOW, new JSONObject().put("action", "uploadNow").put("pid", j).put("path", str).put("label", str2), nativeCallback);
}
return spawnThread;
}
public static JSONObject logMessage(String str) throws JSONException {
return call(new JSONObject().put("action", "logMessage").put("message", str), null);
}
public static JSONObject sendLogs(NativeCallback nativeCallback) throws JSONException {
return call("sendLogs", null);
}
public static JSONObject abortUploadNow() throws JSONException {
return call("abortUploadNow", null);
}
public static JSONObject downloadNow(long j, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.DOWNLOAD_NOW, new JSONObject().put("action", "downloadNow").put("syncid", j).put("availbytes", availSpaceOnExtStorage()), nativeCallback);
}
public static JSONObject filenameExist(String str, long j) throws JSONException {
return call(new JSONObject().put("action", "filenameexists").put("label", str).put("pid", j).put("whereflags", 0).put("orderflags", ORDER_BY_NAME), null);
}
public static JSONObject copywait(JSONArray jSONArray, long j) throws JSONException {
return call(new JSONObject().put("action", "copytowait").put("infolist", jSONArray).put("pid", j), null);
}
public static JSONObject movewaitskipexist(JSONArray jSONArray, long j) throws JSONException {
return call(new JSONObject().put("action", "movetoskipexistwait").put("infolist", jSONArray).put("pid", j), null);
}
public static JSONObject shareGetInvitePassword(long j, String str) throws JSONException {
return call(new JSONObject().put("action", "share_get_invite_password").put("share_id", j).put("user_pubkey", str), null);
}
public static JSONObject rename(String str, long j, long j2, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.RENAME, new JSONObject().put("action", "rename").put("label", str).put("pid", j).put("syncid", j2), nativeCallback);
}
public static JSONObject copyto(JSONArray jSONArray, long j, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.COPYTO, new JSONObject().put("action", "copyto").put("infolist", jSONArray).put("pid", j), nativeCallback);
}
public static JSONObject downloadNow(long j, NativeCallback nativeCallback, boolean z) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.DOWNLOAD_NOW, new JSONObject().put("action", "downloadNow").put("offline", z ? 1 : 0).put("syncid", j).put("availbytes", availSpaceOnExtStorage()), nativeCallback);
}
public static JSONObject abortDownloadNow() throws JSONException {
return call("abortDownloadNow", null);
}
public static JSONObject abortDecryptFile() throws JSONException {
return call("abortDecryptFile", null);
}
public static JSONObject abortBGDownloadSyncid(long j) throws JSONException {
return call(new JSONObject().put("action", "abortBGDownloadSyncid").put("syncid", j), null);
}
public static JSONObject abortCameraUpload() throws JSONException {
return call(new JSONObject().put("action", "abortBGDownload"), null);
}
public static JSONObject resumeCameraUpload() throws JSONException {
return call(new JSONObject().put("action", "resumeBGDownload"), null);
}
public static synchronized JSONObject downloadAddToQueue(long j, String str) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call(new JSONObject().put("action", "downloadAddToQueue").put("batchid", str).put("syncid", j).put("availbytes", availSpaceOnExtStorage()), null);
if (BG_DOWNLOAD_THREAD != null) {
BG_DOWNLOAD_THREAD.interrupt();
}
}
return call;
}
public static JSONObject downloadPurgeBatch(String str) throws JSONException {
return call(new JSONObject().put("action", "purgeIOBatch").put("type", "downqueue").put("batchid", str), null);
}
public static JSONObject uploadPurgeBatch(String str) throws JSONException {
return call(new JSONObject().put("action", "purgeIOBatch").put("type", "upqueue").put("batchid", str), null);
}
public static JSONObject updateCamDir(NativeCallback nativeCallback) throws JSONException {
return call(new JSONObject().put("action", "updateCamUpload"), nativeCallback);
}
public static JSONObject autoUploadPurgeIOBatch() throws JSONException {
return call(new JSONObject().put("action", "purgeIOBatch").put("type", "autoupqueue").put("batchid", "main"), null);
}
public static JSONObject autoUploadPurgeDoneJobs() throws JSONException {
return call(new JSONObject().put("action", "autoUploadPurgeDone").put("type", "autoupqueue").put("batchid", "main"), null);
}
public static JSONObject autoUploadMoveIOBatch() throws JSONException {
return call(new JSONObject().put("action", "moveIOBatch").put("type", "autoupqueue").put("batchid", "main"), null);
}
public static JSONObject autoUploadPurgeAll() throws JSONException {
return call(new JSONObject().put("action", "autoUploadStop").put("mode", 1), null);
}
public static JSONObject autoUploadPurgePending() throws JSONException {
return call(new JSONObject().put("action", "autoUploadStop").put("mode", 2), null);
}
public static JSONObject autoUploadgetStatus() throws JSONException {
return call(new JSONObject().put("action", "autoUploadStatus"), null);
}
public static Boolean organize_cameraupload() {
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(APP_CONTEXT);
boolean z = false;
Boolean valueOf = Boolean.valueOf(defaultSharedPreferences.getBoolean("pref_app_organized_cameraupload", false));
Boolean valueOf2 = Boolean.valueOf(defaultSharedPreferences.getBoolean("pref_app_cameraupload_enable", false));
if (valueOf.booleanValue() && valueOf2.booleanValue()) {
z = true;
}
return Boolean.valueOf(z);
}
public static Boolean get_organize_cameraupload() {
return Boolean.valueOf(PreferenceManager.getDefaultSharedPreferences(APP_CONTEXT).getBoolean("pref_app_organized_cameraupload", true));
}
public static void set_organize_cameraupload(boolean z) {
Boolean.valueOf(PreferenceManager.getDefaultSharedPreferences(APP_CONTEXT).getBoolean("pref_app_organized_cameraupload", z));
}
public static Boolean default_cameraupload() {
return Boolean.valueOf(PreferenceManager.getDefaultSharedPreferences(APP_CONTEXT).getBoolean("pref_app_cameraupload_default", true));
}
public static Boolean revert_cameraupload() {
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(APP_CONTEXT);
boolean z = false;
Boolean valueOf = Boolean.valueOf(defaultSharedPreferences.getBoolean("pref_app_organized_cameraupload", false));
Boolean valueOf2 = Boolean.valueOf(defaultSharedPreferences.getBoolean("pref_app_cameraupload_enable", false));
if (!valueOf.booleanValue() && valueOf2.booleanValue()) {
z = true;
}
return Boolean.valueOf(z);
}
public static long camuploadid() {
try {
return call(new JSONObject().put("action", "CamUploadid"), null).getLong("camuploadid");
} catch (JSONException unused) {
return 0L;
}
}
public static long Secondarycamuploadid() {
try {
return call(new JSONObject().put("action", "SecondaryCamUploadid"), null).getLong("camuploadid");
} catch (JSONException unused) {
return 0L;
}
}
public static long setCameraUploadName(String str) {
try {
return call(new JSONObject().put("action", "setCameraUpload").put("label", str), null).getLong("camuploadid");
} catch (JSONException unused) {
return 0L;
}
}
public static String getCameraUploadName() {
try {
return call(new JSONObject().put("action", "getCameraUpload"), null).getString("cameraupName");
} catch (JSONException unused) {
return "Camera Upload";
}
}
public static JSONObject fileprovidermkdir(String str, long j) throws JSONException {
return call(new JSONObject().put("action", "fileprovidermkdir").put("label", str).put("pid", j), null);
}
public static synchronized JSONObject autoUploadAddToQueue(String str, String str2, String str3, long j, String str4) throws JSONException {
synchronized (NativeApi.class) {
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(APP_CONTEXT);
long j2 = defaultSharedPreferences.getLong("pref_app_cameraupload_starttime", 0L);
long parseLong = Long.parseLong(str2);
if (j2 > parseLong) {
SyncApplication.logwrite(TAG, "start Time is greater than file mtime, skip");
return error(1157627906);
}
File file = new File(str);
String uri = Uri.fromFile(file).toString();
SyncApplication.logwrite(TAG, "auto upload reading file from " + file.getAbsolutePath() + " path: " + str);
if (!file.exists()) {
SyncApplication.logwrite(TAG, "Could not auto upload " + str + " Not exist, but still add task to todo file");
} else if (!file.canRead()) {
SyncApplication.logwrite(TAG, "Could not auto upload " + str + " Cannot read, but still add task to todo file");
}
if (UploadUtils.isAutoUploaded(APP_CONTEXT, uri)) {
return error(1157627906);
}
long j3 = defaultSharedPreferences.getBoolean("pref_app_cameraupload_video", true) ? 1L : 0L;
SyncApplication.logwrite(TAG, "start time " + j2 + " filemtime " + parseLong);
SharedPreferences.Editor edit = defaultSharedPreferences.edit();
edit.putLong("pref_app_cameraupload_starttime", parseLong);
Log.d(TAG, "Timestamp is set " + parseLong + " > " + j2);
edit.apply();
UploadUtils.markFileAutoUploaded(APP_CONTEXT, uri);
return call(new JSONObject().put("action", "autoUploadAddToQueue").put("fileid", str4).put("dateadded", str2).put("name", file.getName()).put("mime", str3).put("isdefault", j3).put("uploadtoid", j).put("mediaid", str4), null);
}
}
public static JSONObject dirtyProcess(NativeCallback nativeCallback) throws JSONException {
return call(new JSONObject().put("action", "dirtyProcess").put("pid", -1).put("maxiter", 20), nativeCallback);
}
public static JSONObject batchDeleteInfo(long j) throws JSONException {
return call(new JSONObject().put("action", "fileproviderDeleteinfo").put("syncid", j), null);
}
public static JSONObject batchCopyInfo(long j, long j2) throws JSONException {
return call(new JSONObject().put("action", "fileproviderCopyinfo").put("syncpid", j2).put("syncid", j), null);
}
public static JSONObject renameFolderInfo(long j, long j2, int i, String str) throws JSONException {
return call(new JSONObject().put("action", "folderRenameInfo").put("syncpid", j2).put("syncid", j).put("newlabel", str).put("isparent", i), null);
}
public static JSONObject upstreamWait(String str, JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "upstreamwait").put("cmdname", str).put("cmdin", jSONObject), null);
}
public static JSONObject dumpdir(long j, String str) throws JSONException {
return call(new JSONObject().put("action", "batchdumpdir").put("active_level", str).put("syncid", j), null);
}
public static synchronized int autoUploadAddToQueue(Cursor cursor) throws JSONException {
String string;
synchronized (NativeApi.class) {
int columnIndex = cursor.getColumnIndex("_data");
int columnIndex2 = cursor.getColumnIndex("mime_type");
int columnIndex3 = cursor.getColumnIndex("date_modified");
int columnIndex4 = cursor.getColumnIndex("date_added");
int columnIndex5 = cursor.getColumnIndex("_id");
if (columnIndex < 0) {
SyncApplication.logwrite(TAG, "autoupload add to queue failed. cursor does not have DATA column");
return 1;
}
String string2 = cursor.getString(columnIndex);
if (columnIndex3 > 0) {
string = cursor.getString(columnIndex3);
} else {
string = columnIndex4 > 0 ? cursor.getString(columnIndex4) : "";
}
String string3 = columnIndex2 < 0 ? "" : cursor.getString(columnIndex2);
String string4 = cursor.getString(columnIndex5);
SyncApplication.log(TAG, "camera upload add to queue " + string4);
if (PreferenceManager.getDefaultSharedPreferences(APP_CONTEXT).getLong("pref_app_cameraupload_starttime", 0L) > Long.parseLong(string)) {
SyncApplication.log(TAG, "start Time is greater than file mtime, skip");
} else {
long syncidtoAutoUpload = UploadUtils.syncidtoAutoUpload(string);
try {
SyncApplication.logwrite(TAG, "auto upload to queue " + string4);
autoUploadAddToQueue(string2, string, string3, syncidtoAutoUpload, string4);
Thread.sleep(100L);
CameraUploadOrganizer.getInstance().updateCameraStatus("", "");
} catch (InterruptedException unused) {
SyncApplication.log(TAG, "Autoupload add to queue sleep failed");
} catch (JSONException unused2) {
SyncApplication.log(TAG, "Autoupload add to queue failed.");
}
}
return 0;
}
}
public static synchronized JSONObject uploadAddToQueue(String str, String str2, String str3, long j) throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
JSONObject thumbParams = getThumbParams();
String make = Thumbnail.make(str, thumbParams.getInt("thumb1size"), thumbParams.getInt("thumb1size"), true, thumbParams.getInt("thumb1quality"));
call = call(new JSONObject().put("action", "uploadAddToQueue").put("batchid", str3).put("pid", j).put("path", str).put("label", str2).put("thumb1", make).put("thumb2", Thumbnail.make(str, thumbParams.getInt("thumb2size"), thumbParams.getInt("thumb2size"), false, thumbParams.getInt("thumb2quality"))), null);
if (BG_UPLOAD_CB != null) {
BG_UPLOAD_THREAD.interrupt();
}
}
return call;
}
public static JSONObject upstreamAPI(String str, JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.UPSTREAM_API, new JSONObject().put("action", "upstreamAPI").put("cmdname", str).put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject multidelete(JSONArray jSONArray) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.UPSTREAM_API, new JSONObject().put("action", "multidelete").put("infolist", jSONArray), null);
}
public static JSONObject createPublink(long j, boolean z, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.CREATE_PUBLINK, new JSONObject().put("action", "createPublink").put("syncid", j).put("compat", z ? 1 : 0), nativeCallback);
}
public static JSONObject mkdir(String str, long j, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.MKDIR, new JSONObject().put("action", "mkdir").put("pid", j).put("label", str), nativeCallback);
}
public static JSONObject delete(long j, long j2, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.DELETE, new JSONObject().put("action", "batchdelete").put("pid", j2).put("syncid", j), nativeCallback);
}
public static JSONObject getEvents(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.GETEVENTS, new JSONObject().put("action", "getevents").put("cmdname", "eventslist").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject getShareList(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHARE, new JSONObject().put("action", "share").put("cmdname", "sharelist").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject getShareListWait(JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "sharewait").put("cmdname", "sharelist").put("cmdin", jSONObject), null);
}
public static JSONObject getPasswordSalt(JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "getPasswordSalt").put("cmdname", "getloginsalt").put("cmdin", jSONObject), null);
}
public static JSONObject authTwoFA(JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "authtwofa").put("cmdname", "sessionnew").put("cmdin", jSONObject), null);
}
public static JSONObject getPasswordHash(String str, String str2) throws JSONException {
return call(new JSONObject().put("action", "getPasswordHash").put("password", str).put("salt", str2), null);
}
public static JSONObject getDirInfo(JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "upstreamwait").put("cmdname", "getdirusage").put("cmdin", jSONObject), null);
}
public static JSONObject manualRefresh(JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "upstreamwait").put("cmdname", "refresh").put("cmdin", jSONObject), null);
}
public static JSONObject userinfoset(JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "upstreamwait").put("cmdname", "userinfoset").put("cmdin", jSONObject), null);
}
public static JSONObject leaveShareWait(JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "sharewait").put("cmdname", "sharememberleave").put("cmdin", jSONObject), null);
}
public static JSONObject acceptShareWait(JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "sharewait").put("cmdname", "shareaccept").put("cmdin", jSONObject), null);
}
public static JSONObject getShareListFilesFragment(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHAREFILE, new JSONObject().put("action", "share").put("cmdname", "sharelist").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject getShareInvite(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHARE, new JSONObject().put("action", "share").put("cmdname", "shareinvite").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject sharecheck(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHARE, new JSONObject().put("action", "share").put("cmdname", "sharecheck").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject shareCreate(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHARE, new JSONObject().put("action", "sharecreate").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject shareAccpet(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHARE, new JSONObject().put("action", "share").put("cmdname", "shareaccept").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject shareDisable(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHARE, new JSONObject().put("action", "share").put("cmdname", "sharestop").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject shareDisableWait(JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "sharewait").put("cmdname", "sharestop").put("cmdin", jSONObject), null);
}
public static JSONObject shareLeave(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHARE, new JSONObject().put("action", "share").put("cmdname", "sharememberleave").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject shareRemoveUsers(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHARE, new JSONObject().put("action", "shareuserdel").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject shareAddMember(JSONObject jSONObject, long j, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHARE, new JSONObject().put("action", "sharememberadd").put("share_id", j).put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject getShare(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHARE, new JSONObject().put("action", "share").put("cmdname", "shareget").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject getShareWait(JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "sharewait").put("cmdname", "shareget").put("cmdin", jSONObject), null);
}
public static JSONObject sharepermchange(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHARE, new JSONObject().put("action", "share").put("cmdname", "sharememberpermission").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject sharepermAddInvite(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.SHARE, new JSONObject().put("action", "share").put("cmdname", "grantinvitepermission").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject eventsFetchThumbs(JSONArray jSONArray, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.EVENTSTHUMBS, new JSONObject().put("action", "eventGetThumb").put("listofsyncid", jSONArray).put("provider", 1), nativeCallback);
}
public static JSONObject publinkget(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.PUBLINK, new JSONObject().put("action", "publink").put("cmdname", "linkpathlist").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject publinkpathdata(JSONObject jSONObject, NativeCallback nativeCallback) throws JSONException {
return spawnThread(NativeApiHelper.ThreadedNativeCall.PUBLINK, new JSONObject().put("action", "publink").put("cmdname", "pathdata").put("cmdin", jSONObject), nativeCallback);
}
public static JSONObject publinkpathlist(JSONObject jSONObject, String str) throws JSONException {
return call(new JSONObject().put("action", "getPubLinkPathList").put("response", jSONObject.toString()).put("password", str), null);
}
public static synchronized JSONObject signup(String str, String str2, boolean z, NativeCallback nativeCallback) throws JSONException {
JSONObject provision;
synchronized (NativeApi.class) {
provision = provision(str, "", "", str2, true, z, nativeCallback);
}
return provision;
}
public static synchronized JSONObject attach(String str, String str2, String str3, NativeCallback nativeCallback) throws JSONException {
JSONObject provision;
synchronized (NativeApi.class) {
provision = provision(str, "", "", str2, false, str3, nativeCallback);
}
return provision;
}
public static synchronized JSONObject unprovision() throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call("unprovision", null);
}
return call;
}
public static synchronized JSONObject isProvisioned() throws JSONException {
JSONObject call;
synchronized (NativeApi.class) {
call = call("isProvisioned", null);
}
return call;
}
public static synchronized String wormhole(String str) {
String processWormhole;
synchronized (NativeApi.class) {
try {
processWormhole = processWormhole(str);
} catch (Exception e) {
log("wormhole exception: ", e);
return "{\"errcode\" : 1 }";
}
}
return processWormhole;
}
public static JSONObject previewDownloadURL(long j) throws JSONException {
return call(new JSONObject().put("action", "previewDownloadURL").put("syncid", j), null);
}
public static JSONObject userVerifyPassword(JSONObject jSONObject) throws JSONException {
return call(new JSONObject().put("action", "upstreamwait").put("cmdname", "userverifypassword").put("cmdin", jSONObject), null);
}
}