package com.BOBs.BBS;


import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.B4AClass;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.debug.*;

public class cdropbox extends B4AClass.ImplB4AClass implements BA.SubDelegator{
    private static java.util.HashMap<String, java.lang.reflect.Method> htSubs;
    private void innerInitialize(BA _ba) throws Exception {
        if (ba == null) {
            ba = new BA(_ba, this, htSubs, "com.BOBs.BBS.cdropbox");
            if (htSubs == null) {
                ba.loadHtSubs(this.getClass());
                htSubs = ba.htSubs;
            }
            
        }
        if (BA.isShellModeRuntimeCheck(ba)) 
			   this.getClass().getMethod("_class_globals", com.BOBs.BBS.cdropbox.class).invoke(this, new Object[] {null});
        else
            ba.raiseEvent2(null, true, "class_globals", false);
    }

 public anywheresoftware.b4a.keywords.Common __c = null;
public String _version = "";
public String _define_dropbox_default_website = "";
public String _define_dropbox_default_path = "";
public String _define_dropbox_default_pathfiles = "";
public String _define_dropbox_default_content_pathfiles = "";
public String _define_dropbox_token_fn = "";
public int _mlasthttpcode = 0;
public String _refreshtoken = "";
public String _appkey = "";
public String _appsecret = "";
public String _accesstoken = "";
public com.BOBs.BOBsCommon.cfileinfo _cfileinfo = null;
public com.BOBs.BOBsCommon.ckey _ckey = null;
public com.BOBs.BOBsCommon.cdirectory _cdirectory = null;
public com.BOBs.BOBsCommon.csnapshot _csnapshot = null;
public com.BOBs.BOBsCommon.ccolors _ccolors = null;
public com.BOBs.BOBsCommon.cgridx _cgridx = null;
public com.BOBs.BOBsCommon.cradiobutton _cradiobutton = null;
public com.BOBs.BOBsCommon.crelativeposition _crelativeposition = null;
public com.BOBs.BOBsCommon.cspecialcharacters _cspecialcharacters = null;
public b4a.example.dateutils _dateutils = null;
public com.BOBs.BBS.main _main = null;
public com.BOBs.BBS.cbbsglobals _cbbsglobals = null;
public com.BOBs.BBS.cagecheck _cagecheck = null;
public com.BOBs.BBS.cbitmaploader _cbitmaploader = null;
public com.BOBs.BBS.cdatabase _cdatabase = null;
public com.BOBs.BBS.cdecrypt _cdecrypt = null;
public com.BOBs.BBS.cdoubles _cdoubles = null;
public com.BOBs.BBS.cfile _cfile = null;
public com.BOBs.BBS.cgenfuncs _cgenfuncs = null;
public com.BOBs.BBS.chowto _chowto = null;
public com.BOBs.BBS.cleaguesecretarydb _cleaguesecretarydb = null;
public com.BOBs.BBS.cmapstuff _cmapstuff = null;
public com.BOBs.BBS.cmessages _cmessages = null;
public com.BOBs.BBS.cnamesdb _cnamesdb = null;
public com.BOBs.BBS.cplayervsplayer _cplayervsplayer = null;
public com.BOBs.BBS.cpropercase _cpropercase = null;
public com.BOBs.BBS.cqrcode _cqrcode = null;
public com.BOBs.BBS.creplay _creplay = null;
public com.BOBs.BBS.ctournaments _ctournaments = null;
public com.BOBs.BBS.ctree _ctree = null;
public com.BOBs.BBS.cuserpreferences _cuserpreferences = null;
public com.BOBs.BBS.xuiviewsutils _xuiviewsutils = null;
public com.BOBs.BBS.b4xpages _b4xpages = null;
public com.BOBs.BBS.b4xcollections _b4xcollections = null;
public com.BOBs.BBS.chttpcodes _chttpcodes = null;
public com.BOBs.BBS.httputils2service _httputils2service = null;
public static class _cdropbox_listitemtype{
public boolean IsInitialized;
public String Name;
public boolean IsDirectory;
public String HRef;
public long LastModified;
public void Initialize() {
IsInitialized = true;
Name = "";
IsDirectory = false;
HRef = "";
LastModified = 0L;
}
@Override
		public String toString() {
			return BA.TypeToString(this, false);
		}}
public String  _class_globals() throws Exception{
 //BA.debugLineNum = 8;BA.debugLine="Sub Class_Globals";
 //BA.debugLineNum = 9;BA.debugLine="Private Const Version                    				A";
_version = "2.2";
 //BA.debugLineNum = 11;BA.debugLine="Type	cDropBox_ListItemType(Name As String, IsDire";
;
 //BA.debugLineNum = 13;BA.debugLine="Private Const DEFINE_DropBox_Default_WebSite";
_define_dropbox_default_website = "https://api.dropboxapi.com";
 //BA.debugLineNum = 14;BA.debugLine="Private Const DEFINE_DropBox_Default_Path";
_define_dropbox_default_path = (""+__c.SmartStringFormatter("",(Object)(_define_dropbox_default_website))+"/2");
 //BA.debugLineNum = 15;BA.debugLine="Private Const DEFINE_DropBox_Default_PathFiles";
_define_dropbox_default_pathfiles = (""+__c.SmartStringFormatter("",(Object)(_define_dropbox_default_path))+"/files");
 //BA.debugLineNum = 17;BA.debugLine="Private Const DEFINE_DropBox_Default_Content_P";
_define_dropbox_default_content_pathfiles = ("https://content.dropboxapi.com/2/files");
 //BA.debugLineNum = 20;BA.debugLine="Private Const DEFINE_DropBox_Token_FN	 				As Str";
_define_dropbox_token_fn = "dropbox_token.txt";
 //BA.debugLineNum = 21;BA.debugLine="Private mLastHTTPCode                    				A";
_mlasthttpcode = 0;
 //BA.debugLineNum = 22;BA.debugLine="Private RefreshToken                     				A";
_refreshtoken = "";
 //BA.debugLineNum = 23;BA.debugLine="Private AppKey                           				A";
_appkey = "";
 //BA.debugLineNum = 24;BA.debugLine="Private AppSecret                        				A";
_appsecret = "";
 //BA.debugLineNum = 25;BA.debugLine="Private AccessToken										As String";
_accesstoken = "";
 //BA.debugLineNum = 26;BA.debugLine="End Sub";
return "";
}
public anywheresoftware.b4a.keywords.Common.ResumableSubWrapper  _createdirectory(String _xfolderpath) throws Exception{
ResumableSub_CreateDirectory rsub = new ResumableSub_CreateDirectory(this,_xfolderpath);
rsub.resume(ba, null);
return (anywheresoftware.b4a.keywords.Common.ResumableSubWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.keywords.Common.ResumableSubWrapper(), rsub);
}
public static class ResumableSub_CreateDirectory extends BA.ResumableSub {
public ResumableSub_CreateDirectory(com.BOBs.BBS.cdropbox parent,String _xfolderpath) {
this.parent = parent;
this._xfolderpath = _xfolderpath;
}
com.BOBs.BBS.cdropbox parent;
String _xfolderpath;
boolean _success;
boolean _doesexist;
com.BOBs.BBS.httpjob _j;
String _xurl = "";
String _xbody = "";

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
{
parent.__c.ReturnFromResumableSub(this,null);return;}
case 0:
//C
this.state = 1;
 //BA.debugLineNum = 41;BA.debugLine="Wait For (EnsureAccessToken) Complete (Succe";
parent.__c.WaitFor("complete", ba, this, parent._ensureaccesstoken());
this.state = 21;
return;
case 21:
//C
this.state = 1;
_success = (Boolean) result[0];
;
 //BA.debugLineNum = 43;BA.debugLine="If 	Success = False Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_success==parent.__c.False) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 44;BA.debugLine="Return False";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.False));return;};
 if (true) break;

case 4:
//C
this.state = 5;
;
 //BA.debugLineNum = 47;BA.debugLine="wait for (Exists(xFolderPath)) Complete(DoesExi";
parent.__c.WaitFor("complete", ba, this, parent._exists(_xfolderpath));
this.state = 22;
return;
case 22:
//C
this.state = 5;
_doesexist = (Boolean) result[0];
;
 //BA.debugLineNum = 49;BA.debugLine="If  DoesExist Then";
if (true) break;

case 5:
//if
this.state = 8;
if (_doesexist) { 
this.state = 7;
}if (true) break;

case 7:
//C
this.state = 8;
 //BA.debugLineNum = 50;BA.debugLine="Return DoesExist";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(_doesexist));return;};
 if (true) break;

case 8:
//C
this.state = 9;
;
 //BA.debugLineNum = 53;BA.debugLine="Dim j As HttpJob";
_j = new com.BOBs.BBS.httpjob();
 //BA.debugLineNum = 54;BA.debugLine="j.Initialize(\"CreateDirectory\", Me)";
_j._initialize /*String*/ (ba,"CreateDirectory",parent);
 //BA.debugLineNum = 56;BA.debugLine="Dim xUrl As String = $\"${DEFINE_DropBox_Defa";
_xurl = (""+parent.__c.SmartStringFormatter("",(Object)(parent._define_dropbox_default_pathfiles))+"/create_folder_v2");
 //BA.debugLineNum = 58;BA.debugLine="If 	Not(xFolderPath.StartsWith(\"/\")) Then";
if (true) break;

case 9:
//if
this.state = 12;
if (parent.__c.Not(_xfolderpath.startsWith("/"))) { 
this.state = 11;
}if (true) break;

case 11:
//C
this.state = 12;
 //BA.debugLineNum = 59;BA.debugLine="xFolderPath = \"/\" & xFolderPath";
_xfolderpath = "/"+_xfolderpath;
 if (true) break;

case 12:
//C
this.state = 13;
;
 //BA.debugLineNum = 62;BA.debugLine="Dim xBody As String = \"{\"\"path\"\": \"\"\" & xFol";
_xbody = "{\"path\": \""+_xfolderpath+"\",\"autorename\": false}";
 //BA.debugLineNum = 64;BA.debugLine="j.PostString(xUrl, xBody)";
_j._poststring /*String*/ (_xurl,_xbody);
 //BA.debugLineNum = 65;BA.debugLine="j.GetRequest.SetHeader(\"Authorization\", \"Bea";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Authorization","Bearer "+parent._accesstoken);
 //BA.debugLineNum = 66;BA.debugLine="j.GetRequest.SetContentType(\"application/jso";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetContentType("application/json");
 //BA.debugLineNum = 68;BA.debugLine="Wait For (j) JobDone(j As HttpJob)";
parent.__c.WaitFor("jobdone", ba, this, (Object)(_j));
this.state = 23;
return;
case 23:
//C
this.state = 13;
_j = (com.BOBs.BBS.httpjob) result[0];
;
 //BA.debugLineNum = 70;BA.debugLine="mLastHTTPCode = j.Response.StatusCode";
parent._mlasthttpcode = _j._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ .getStatusCode();
 //BA.debugLineNum = 72;BA.debugLine="If 	j.Success Then";
if (true) break;

case 13:
//if
this.state = 20;
if (_j._success /*boolean*/ ) { 
this.state = 15;
}else if(_j._errormessage /*String*/ .toLowerCase(anywheresoftware.b4a.keywords.Common.stringLocale).contains("conflict/folder")) { 
this.state = 17;
}else {
this.state = 19;
}if (true) break;

case 15:
//C
this.state = 20;
 //BA.debugLineNum = 73;BA.debugLine="Log(\"Folder created: \" & xFolderPath)";
parent.__c.LogImpl("9243990561","Folder created: "+_xfolderpath,0);
 if (true) break;

case 17:
//C
this.state = 20;
 //BA.debugLineNum = 75;BA.debugLine="Log(\"Folder already exists: \" & xFol";
parent.__c.LogImpl("9243990563","Folder already exists: "+_xfolderpath,0);
 if (true) break;

case 19:
//C
this.state = 20;
 //BA.debugLineNum = 77;BA.debugLine="Log(\"CreateDirectory Error: \" & j.Err";
parent.__c.LogImpl("9243990565","CreateDirectory Error: "+_j._errormessage /*String*/ ,0);
 if (true) break;

case 20:
//C
this.state = -1;
;
 //BA.debugLineNum = 80;BA.debugLine="Return j.Success";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(_j._success /*boolean*/ ));return;};
 //BA.debugLineNum = 81;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public void  _complete(boolean _success) throws Exception{
}
public void  _jobdone(com.BOBs.BBS.httpjob _j) throws Exception{
}
public anywheresoftware.b4a.keywords.Common.ResumableSubWrapper  _deletefile(String _xremotepath) throws Exception{
ResumableSub_DeleteFile rsub = new ResumableSub_DeleteFile(this,_xremotepath);
rsub.resume(ba, null);
return (anywheresoftware.b4a.keywords.Common.ResumableSubWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.keywords.Common.ResumableSubWrapper(), rsub);
}
public static class ResumableSub_DeleteFile extends BA.ResumableSub {
public ResumableSub_DeleteFile(com.BOBs.BBS.cdropbox parent,String _xremotepath) {
this.parent = parent;
this._xremotepath = _xremotepath;
}
com.BOBs.BBS.cdropbox parent;
String _xremotepath;
boolean _success;
com.BOBs.BBS.httpjob _j;
String _xurl = "";
String _xbody = "";
boolean _wasdeleted = false;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
{
parent.__c.ReturnFromResumableSub(this,null);return;}
case 0:
//C
this.state = 1;
 //BA.debugLineNum = 92;BA.debugLine="Wait For (EnsureAccessToken) Complete (Succe";
parent.__c.WaitFor("complete", ba, this, parent._ensureaccesstoken());
this.state = 13;
return;
case 13:
//C
this.state = 1;
_success = (Boolean) result[0];
;
 //BA.debugLineNum = 94;BA.debugLine="If  Success = False Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_success==parent.__c.False) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 95;BA.debugLine="Return False";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.False));return;};
 if (true) break;

case 4:
//C
this.state = 5;
;
 //BA.debugLineNum = 98;BA.debugLine="Dim j As HttpJob";
_j = new com.BOBs.BBS.httpjob();
 //BA.debugLineNum = 100;BA.debugLine="j.Initialize(\"Delete\",  Me)";
_j._initialize /*String*/ (ba,"Delete",parent);
 //BA.debugLineNum = 102;BA.debugLine="Dim xUrl As String = $\"${DEFINE_DropBox_Defa";
_xurl = (""+parent.__c.SmartStringFormatter("",(Object)(parent._define_dropbox_default_pathfiles))+"/delete_v2");
 //BA.debugLineNum = 103;BA.debugLine="Dim xBody As String = \"{\"\"path\"\": \"\"\" & xRem";
_xbody = "{\"path\": \""+_xremotepath+"\"}";
 //BA.debugLineNum = 106;BA.debugLine="j.PostString(xUrl, xBody)";
_j._poststring /*String*/ (_xurl,_xbody);
 //BA.debugLineNum = 108;BA.debugLine="j.GetRequest.SetHeader(\"Authorization\", \"Bea";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Authorization","Bearer "+parent._accesstoken);
 //BA.debugLineNum = 109;BA.debugLine="j.GetRequest.SetContentType(\"application/jso";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetContentType("application/json");
 //BA.debugLineNum = 112;BA.debugLine="Wait For (j) JobDone(j As HttpJob)";
parent.__c.WaitFor("jobdone", ba, this, (Object)(_j));
this.state = 14;
return;
case 14:
//C
this.state = 5;
_j = (com.BOBs.BBS.httpjob) result[0];
;
 //BA.debugLineNum = 114;BA.debugLine="mLastHTTPCode = j.Response.StatusCode";
parent._mlasthttpcode = _j._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ .getStatusCode();
 //BA.debugLineNum = 116;BA.debugLine="Dim WasDeleted As Boolean = False";
_wasdeleted = parent.__c.False;
 //BA.debugLineNum = 118;BA.debugLine="If 	j.Success Then";
if (true) break;

case 5:
//if
this.state = 12;
if (_j._success /*boolean*/ ) { 
this.state = 7;
}else if(_j._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ .getStatusCode()==409) { 
this.state = 9;
}else {
this.state = 11;
}if (true) break;

case 7:
//C
this.state = 12;
 //BA.debugLineNum = 119;BA.debugLine="WasDeleted = True";
_wasdeleted = parent.__c.True;
 if (true) break;

case 9:
//C
this.state = 12;
 //BA.debugLineNum = 121;BA.debugLine="WasDeleted = True";
_wasdeleted = parent.__c.True;
 if (true) break;

case 11:
//C
this.state = 12;
 //BA.debugLineNum = 123;BA.debugLine="Log(\"DeleteFile Error: \" & j.ErrorMessage)";
parent.__c.LogImpl("9244056096","DeleteFile Error: "+_j._errormessage /*String*/ ,0);
 if (true) break;

case 12:
//C
this.state = -1;
;
 //BA.debugLineNum = 126;BA.debugLine="j.Release";
_j._release /*String*/ ();
 //BA.debugLineNum = 128;BA.debugLine="Return WasDeleted";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(_wasdeleted));return;};
 //BA.debugLineNum = 129;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public anywheresoftware.b4a.keywords.Common.ResumableSubWrapper  _downloadfile(String _xremotepath,String _xlocalpath,String _xlocalfile) throws Exception{
ResumableSub_DownloadFile rsub = new ResumableSub_DownloadFile(this,_xremotepath,_xlocalpath,_xlocalfile);
rsub.resume(ba, null);
return (anywheresoftware.b4a.keywords.Common.ResumableSubWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.keywords.Common.ResumableSubWrapper(), rsub);
}
public static class ResumableSub_DownloadFile extends BA.ResumableSub {
public ResumableSub_DownloadFile(com.BOBs.BBS.cdropbox parent,String _xremotepath,String _xlocalpath,String _xlocalfile) {
this.parent = parent;
this._xremotepath = _xremotepath;
this._xlocalpath = _xlocalpath;
this._xlocalfile = _xlocalfile;
}
com.BOBs.BBS.cdropbox parent;
String _xremotepath;
String _xlocalpath;
String _xlocalfile;
boolean _success;
com.BOBs.BBS.httpjob _j;
String _xurl = "";

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
{
parent.__c.ReturnFromResumableSub(this,null);return;}
case 0:
//C
this.state = 1;
 //BA.debugLineNum = 137;BA.debugLine="Wait For (EnsureAccessToken) Complete (Succe";
parent.__c.WaitFor("complete", ba, this, parent._ensureaccesstoken());
this.state = 9;
return;
case 9:
//C
this.state = 1;
_success = (Boolean) result[0];
;
 //BA.debugLineNum = 139;BA.debugLine="If  Success = False Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_success==parent.__c.False) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 140;BA.debugLine="Return False";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.False));return;};
 if (true) break;

case 4:
//C
this.state = 5;
;
 //BA.debugLineNum = 143;BA.debugLine="Dim j As HttpJob";
_j = new com.BOBs.BBS.httpjob();
 //BA.debugLineNum = 144;BA.debugLine="j.Initialize(\"Download\",  Me)";
_j._initialize /*String*/ (ba,"Download",parent);
 //BA.debugLineNum = 146;BA.debugLine="Dim xUrl As String = $\"${DEFINE_DropBox_Defa";
_xurl = (""+parent.__c.SmartStringFormatter("",(Object)(parent._define_dropbox_default_content_pathfiles))+"/download");
 //BA.debugLineNum = 148;BA.debugLine="j.Download(xUrl)";
_j._download /*String*/ (_xurl);
 //BA.debugLineNum = 149;BA.debugLine="j.GetRequest.SetHeader(\"Authorization\", \"Bea";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Authorization","Bearer "+parent._accesstoken);
 //BA.debugLineNum = 150;BA.debugLine="j.GetRequest.SetHeader(\"Dropbox-API-Arg\", \"{";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Dropbox-API-Arg","{\"path\": \""+_xremotepath+"\"}");
 //BA.debugLineNum = 153;BA.debugLine="Wait For (j) JobDone(j As HttpJob)";
parent.__c.WaitFor("jobdone", ba, this, (Object)(_j));
this.state = 10;
return;
case 10:
//C
this.state = 5;
_j = (com.BOBs.BBS.httpjob) result[0];
;
 //BA.debugLineNum = 155;BA.debugLine="mLastHTTPCode = j.Response.StatusCode";
parent._mlasthttpcode = _j._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ .getStatusCode();
 //BA.debugLineNum = 157;BA.debugLine="If  j.Success Then";
if (true) break;

case 5:
//if
this.state = 8;
if (_j._success /*boolean*/ ) { 
this.state = 7;
}if (true) break;

case 7:
//C
this.state = 8;
 //BA.debugLineNum = 158;BA.debugLine="File.WriteBytes(xLocalPath, xLocalFile,";
parent.__c.File.WriteBytes(_xlocalpath,_xlocalfile,_j._getstring /*String*/ ().getBytes("UTF8"));
 //BA.debugLineNum = 159;BA.debugLine="Return True";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.True));return;};
 if (true) break;

case 8:
//C
this.state = -1;
;
 //BA.debugLineNum = 162;BA.debugLine="Log(\"Download Error: \" & j.ErrorMessage)";
parent.__c.LogImpl("9244121626","Download Error: "+_j._errormessage /*String*/ ,0);
 //BA.debugLineNum = 163;BA.debugLine="Return False";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.False));return;};
 //BA.debugLineNum = 164;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public anywheresoftware.b4a.keywords.Common.ResumableSubWrapper  _downloadstream(String _xremotepath,anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper _xdownloadstream) throws Exception{
ResumableSub_DownloadStream rsub = new ResumableSub_DownloadStream(this,_xremotepath,_xdownloadstream);
rsub.resume(ba, null);
return (anywheresoftware.b4a.keywords.Common.ResumableSubWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.keywords.Common.ResumableSubWrapper(), rsub);
}
public static class ResumableSub_DownloadStream extends BA.ResumableSub {
public ResumableSub_DownloadStream(com.BOBs.BBS.cdropbox parent,String _xremotepath,anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper _xdownloadstream) {
this.parent = parent;
this._xremotepath = _xremotepath;
this._xdownloadstream = _xdownloadstream;
}
com.BOBs.BBS.cdropbox parent;
String _xremotepath;
anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper _xdownloadstream;
boolean _success;
com.BOBs.BBS.httpjob _j;
String _xurl = "";

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
{
parent.__c.ReturnFromResumableSub(this,null);return;}
case 0:
//C
this.state = 1;
 //BA.debugLineNum = 172;BA.debugLine="Wait For (EnsureAccessToken) Complete (Succe";
parent.__c.WaitFor("complete", ba, this, parent._ensureaccesstoken());
this.state = 9;
return;
case 9:
//C
this.state = 1;
_success = (Boolean) result[0];
;
 //BA.debugLineNum = 174;BA.debugLine="If  Success = False Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_success==parent.__c.False) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 175;BA.debugLine="Return False";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.False));return;};
 if (true) break;

case 4:
//C
this.state = 5;
;
 //BA.debugLineNum = 178;BA.debugLine="Dim j As HttpJob";
_j = new com.BOBs.BBS.httpjob();
 //BA.debugLineNum = 179;BA.debugLine="j.Initialize(\"Download\",  Me)";
_j._initialize /*String*/ (ba,"Download",parent);
 //BA.debugLineNum = 181;BA.debugLine="Dim xUrl As String = $\"${DEFINE_DropBox_Defa";
_xurl = (""+parent.__c.SmartStringFormatter("",(Object)(parent._define_dropbox_default_content_pathfiles))+"/download");
 //BA.debugLineNum = 183;BA.debugLine="j.Download(xUrl)";
_j._download /*String*/ (_xurl);
 //BA.debugLineNum = 184;BA.debugLine="j.GetRequest.SetHeader(\"Authorization\", \"Bea";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Authorization","Bearer "+parent._accesstoken);
 //BA.debugLineNum = 185;BA.debugLine="j.GetRequest.SetHeader(\"Dropbox-API-Arg\", \"{";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Dropbox-API-Arg","{\"path\": \""+_xremotepath+"\"}");
 //BA.debugLineNum = 188;BA.debugLine="Wait For (j) JobDone(j As HttpJob)";
parent.__c.WaitFor("jobdone", ba, this, (Object)(_j));
this.state = 10;
return;
case 10:
//C
this.state = 5;
_j = (com.BOBs.BBS.httpjob) result[0];
;
 //BA.debugLineNum = 190;BA.debugLine="mLastHTTPCode = j.Response.StatusCode";
parent._mlasthttpcode = _j._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ .getStatusCode();
 //BA.debugLineNum = 192;BA.debugLine="If  j.Success Then";
if (true) break;

case 5:
//if
this.state = 8;
if (_j._success /*boolean*/ ) { 
this.state = 7;
}if (true) break;

case 7:
//C
this.state = 8;
 //BA.debugLineNum = 193;BA.debugLine="File.Copy2(j.GetInputStream, xDownloadStream)";
parent.__c.File.Copy2((java.io.InputStream)(_j._getinputstream /*anywheresoftware.b4a.objects.streams.File.InputStreamWrapper*/ ().getObject()),(java.io.OutputStream)(_xdownloadstream.getObject()));
 //BA.debugLineNum = 194;BA.debugLine="Return True";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.True));return;};
 if (true) break;

case 8:
//C
this.state = -1;
;
 //BA.debugLineNum = 197;BA.debugLine="Log(\"Download Error: \" & j.ErrorMessage)";
parent.__c.LogImpl("9244187162","Download Error: "+_j._errormessage /*String*/ ,0);
 //BA.debugLineNum = 198;BA.debugLine="Return False";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.False));return;};
 //BA.debugLineNum = 199;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public anywheresoftware.b4a.keywords.Common.ResumableSubWrapper  _ensureaccesstoken() throws Exception{
ResumableSub_EnsureAccessToken rsub = new ResumableSub_EnsureAccessToken(this);
rsub.resume(ba, null);
return (anywheresoftware.b4a.keywords.Common.ResumableSubWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.keywords.Common.ResumableSubWrapper(), rsub);
}
public static class ResumableSub_EnsureAccessToken extends BA.ResumableSub {
public ResumableSub_EnsureAccessToken(com.BOBs.BBS.cdropbox parent) {
this.parent = parent;
}
com.BOBs.BBS.cdropbox parent;
String _url = "";
com.BOBs.BBS.httpjob _j;
String _xnewtoken;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
{
parent.__c.ReturnFromResumableSub(this,null);return;}
case 0:
//C
this.state = 1;
 //BA.debugLineNum = 208;BA.debugLine="Dim url As String = $\"${DEFINE_DropBox_Default_";
_url = (""+parent.__c.SmartStringFormatter("",(Object)(parent._define_dropbox_default_path))+"/users/get_current_account");
 //BA.debugLineNum = 209;BA.debugLine="Dim j 	As HttpJob";
_j = new com.BOBs.BBS.httpjob();
 //BA.debugLineNum = 211;BA.debugLine="j.Initialize(\"CheckToken\", Me)";
_j._initialize /*String*/ (ba,"CheckToken",parent);
 //BA.debugLineNum = 213;BA.debugLine="j.PostString(url, \"null\")  ' DropBox requires a";
_j._poststring /*String*/ (_url,"null");
 //BA.debugLineNum = 215;BA.debugLine="j.GetRequest.SetHeader(\"Authorization\", \"Bearer";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Authorization","Bearer "+parent._accesstoken);
 //BA.debugLineNum = 216;BA.debugLine="j.GetRequest.SetContentType(\"application/json\")";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetContentType("application/json");
 //BA.debugLineNum = 219;BA.debugLine="Wait For (j) JobDone(j As HttpJob)";
parent.__c.WaitFor("jobdone", ba, this, (Object)(_j));
this.state = 9;
return;
case 9:
//C
this.state = 1;
_j = (com.BOBs.BBS.httpjob) result[0];
;
 //BA.debugLineNum = 221;BA.debugLine="mLastHTTPCode = j.Response.StatusCode";
parent._mlasthttpcode = _j._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ .getStatusCode();
 //BA.debugLineNum = 223;BA.debugLine="If 	j.Success Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_j._success /*boolean*/ ) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 224;BA.debugLine="j.Release";
_j._release /*String*/ ();
 //BA.debugLineNum = 226;BA.debugLine="Return True";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.True));return;};
 if (true) break;

case 4:
//C
this.state = 5;
;
 //BA.debugLineNum = 230;BA.debugLine="j.Release";
_j._release /*String*/ ();
 //BA.debugLineNum = 233;BA.debugLine="Dim xNewToken As String";
_xnewtoken = "";
 //BA.debugLineNum = 235;BA.debugLine="Wait For (RefreshAccessToken(AppKey, AppS";
parent.__c.WaitFor("complete", ba, this, parent._refreshaccesstoken(parent._appkey,parent._appsecret,parent._refreshtoken));
this.state = 10;
return;
case 10:
//C
this.state = 5;
_xnewtoken = (String) result[0];
;
 //BA.debugLineNum = 237;BA.debugLine="If 	xNewToken <> \"\" Then";
if (true) break;

case 5:
//if
this.state = 8;
if ((_xnewtoken).equals("") == false) { 
this.state = 7;
}if (true) break;

case 7:
//C
this.state = 8;
 //BA.debugLineNum = 238;BA.debugLine="AccessToken = xNewToken";
parent._accesstoken = _xnewtoken;
 //BA.debugLineNum = 240;BA.debugLine="Log(\"New Access Token \" &AccessToken)";
parent.__c.LogImpl("9244252706","New Access Token "+parent._accesstoken,0);
 //BA.debugLineNum = 242;BA.debugLine="SaveAccessToken(xNewToken) ' <-- store it";
parent._saveaccesstoken(_xnewtoken);
 //BA.debugLineNum = 243;BA.debugLine="Return True";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.True));return;};
 if (true) break;

case 8:
//C
this.state = -1;
;
 //BA.debugLineNum = 246;BA.debugLine="Log(\"Failed to refresh access token\")";
parent.__c.LogImpl("9244252712","Failed to refresh access token",0);
 //BA.debugLineNum = 249;BA.debugLine="File.Delete(File.DirInternal, DEFINE_DropBox_To";
parent.__c.File.Delete(parent.__c.File.getDirInternal(),parent._define_dropbox_token_fn);
 //BA.debugLineNum = 255;BA.debugLine="Return False";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.False));return;};
 //BA.debugLineNum = 256;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public anywheresoftware.b4a.keywords.Common.ResumableSubWrapper  _exists(String _xpath) throws Exception{
ResumableSub_Exists rsub = new ResumableSub_Exists(this,_xpath);
rsub.resume(ba, null);
return (anywheresoftware.b4a.keywords.Common.ResumableSubWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.keywords.Common.ResumableSubWrapper(), rsub);
}
public static class ResumableSub_Exists extends BA.ResumableSub {
public ResumableSub_Exists(com.BOBs.BBS.cdropbox parent,String _xpath) {
this.parent = parent;
this._xpath = _xpath;
}
com.BOBs.BBS.cdropbox parent;
String _xpath;
boolean _success;
com.BOBs.BBS.httpjob _j;
String _xurl = "";
String _xbody = "";
boolean _xexists = false;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
{
parent.__c.ReturnFromResumableSub(this,null);return;}
case 0:
//C
this.state = 1;
 //BA.debugLineNum = 265;BA.debugLine="Wait For (EnsureAccessToken) Complete (Succe";
parent.__c.WaitFor("complete", ba, this, parent._ensureaccesstoken());
this.state = 15;
return;
case 15:
//C
this.state = 1;
_success = (Boolean) result[0];
;
 //BA.debugLineNum = 267;BA.debugLine="If 	Success = False Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_success==parent.__c.False) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 268;BA.debugLine="Return False";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.False));return;};
 if (true) break;

case 4:
//C
this.state = 5;
;
 //BA.debugLineNum = 271;BA.debugLine="Dim j As HttpJob";
_j = new com.BOBs.BBS.httpjob();
 //BA.debugLineNum = 273;BA.debugLine="j.Initialize(\"ResourceExists\",  Me)";
_j._initialize /*String*/ (ba,"ResourceExists",parent);
 //BA.debugLineNum = 275;BA.debugLine="Dim xUrl As String = $\"${DEFINE_DropBox_Defa";
_xurl = (""+parent.__c.SmartStringFormatter("",(Object)(parent._define_dropbox_default_pathfiles))+"/get_metadata");
 //BA.debugLineNum = 277;BA.debugLine="Dim xBody As String = \"{\"\"path\"\": \"\"\" & xPat";
_xbody = "{\"path\": \""+_xpath+"\",\"include_deleted\": false}";
 //BA.debugLineNum = 279;BA.debugLine="j.PostString(xUrl, xBody)";
_j._poststring /*String*/ (_xurl,_xbody);
 //BA.debugLineNum = 280;BA.debugLine="j.GetRequest.SetHeader(\"Authorization\", \"Bea";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Authorization","Bearer "+parent._accesstoken);
 //BA.debugLineNum = 281;BA.debugLine="j.GetRequest.SetContentType(\"application/jso";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetContentType("application/json");
 //BA.debugLineNum = 283;BA.debugLine="Wait For (j) JobDone(j As HttpJob)";
parent.__c.WaitFor("jobdone", ba, this, (Object)(_j));
this.state = 16;
return;
case 16:
//C
this.state = 5;
_j = (com.BOBs.BBS.httpjob) result[0];
;
 //BA.debugLineNum = 285;BA.debugLine="mLastHTTPCode = j.Response.StatusCode";
parent._mlasthttpcode = _j._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ .getStatusCode();
 //BA.debugLineNum = 287;BA.debugLine="Dim xExists As Boolean = False";
_xexists = parent.__c.False;
 //BA.debugLineNum = 289;BA.debugLine="If 	j.Success Then";
if (true) break;

case 5:
//if
this.state = 14;
if (_j._success /*boolean*/ ) { 
this.state = 7;
}else if(_j._errormessage /*String*/ .toLowerCase(anywheresoftware.b4a.keywords.Common.stringLocale).contains("not_found")) { 
this.state = 9;
}else if(_j._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ .getStatusCode()!=409) { 
this.state = 11;
}else {
this.state = 13;
}if (true) break;

case 7:
//C
this.state = 14;
 //BA.debugLineNum = 290;BA.debugLine="xExists = True";
_xexists = parent.__c.True;
 if (true) break;

case 9:
//C
this.state = 14;
 //BA.debugLineNum = 292;BA.debugLine="xExists = False";
_xexists = parent.__c.False;
 if (true) break;

case 11:
//C
this.state = 14;
 //BA.debugLineNum = 294;BA.debugLine="xExists = False";
_xexists = parent.__c.False;
 if (true) break;

case 13:
//C
this.state = 14;
 //BA.debugLineNum = 296;BA.debugLine="Log(\"ResourceExists Error: \" & j.Erro";
parent.__c.LogImpl("9244318240","ResourceExists Error: "+_j._errormessage /*String*/ ,0);
 if (true) break;

case 14:
//C
this.state = -1;
;
 //BA.debugLineNum = 299;BA.debugLine="j.Release";
_j._release /*String*/ ();
 //BA.debugLineNum = 301;BA.debugLine="Return xExists";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(_xexists));return;};
 //BA.debugLineNum = 302;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public int  _getlasthttpcode() throws Exception{
 //BA.debugLineNum = 306;BA.debugLine="Public 	Sub GetLastHTTPCode As Int";
 //BA.debugLineNum = 307;BA.debugLine="Return mLastHTTPCode";
if (true) return _mlasthttpcode;
 //BA.debugLineNum = 308;BA.debugLine="End Sub";
return 0;
}
public anywheresoftware.b4a.keywords.Common.ResumableSubWrapper  _gettokens(String _xappkey,String _xappsecret,String _xauthcode) throws Exception{
ResumableSub_GetTokens rsub = new ResumableSub_GetTokens(this,_xappkey,_xappsecret,_xauthcode);
rsub.resume(ba, null);
return (anywheresoftware.b4a.keywords.Common.ResumableSubWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.keywords.Common.ResumableSubWrapper(), rsub);
}
public static class ResumableSub_GetTokens extends BA.ResumableSub {
public ResumableSub_GetTokens(com.BOBs.BBS.cdropbox parent,String _xappkey,String _xappsecret,String _xauthcode) {
this.parent = parent;
this._xappkey = _xappkey;
this._xappsecret = _xappsecret;
this._xauthcode = _xauthcode;
}
com.BOBs.BBS.cdropbox parent;
String _xappkey;
String _xappsecret;
String _xauthcode;
com.BOBs.BBS.httpjob _j;
String _postdata = "";
anywheresoftware.b4a.objects.collections.Map _m = null;
anywheresoftware.b4a.objects.collections.JSONParser _parser = null;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
{
parent.__c.ReturnFromResumableSub(this,null);return;}
case 0:
//C
this.state = 1;
 //BA.debugLineNum = 320;BA.debugLine="Dim j As HttpJob";
_j = new com.BOBs.BBS.httpjob();
 //BA.debugLineNum = 322;BA.debugLine="j.Initialize(\"GetTokens\", Me)";
_j._initialize /*String*/ (ba,"GetTokens",parent);
 //BA.debugLineNum = 324;BA.debugLine="Dim postData As String = _         			\"code=";
_postdata = "code="+_xauthcode+"&grant_type=authorization_code"+"&client_id="+_xappkey+"&client_secret="+_xappsecret;
 //BA.debugLineNum = 334;BA.debugLine="j.PostString($\"${DEFINE_DropBox_Default_WebS";
_j._poststring /*String*/ ((""+parent.__c.SmartStringFormatter("",(Object)(parent._define_dropbox_default_website))+"/oauth2/token"),_postdata);
 //BA.debugLineNum = 335;BA.debugLine="j.GetRequest.SetHeader(\"Content-Type\", \"appl";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Content-Type","application/x-www-form-urlencoded");
 //BA.debugLineNum = 337;BA.debugLine="Wait For (j) JobDone(j As HttpJob)";
parent.__c.WaitFor("jobdone", ba, this, (Object)(_j));
this.state = 5;
return;
case 5:
//C
this.state = 1;
_j = (com.BOBs.BBS.httpjob) result[0];
;
 //BA.debugLineNum = 339;BA.debugLine="Dim m As Map";
_m = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 341;BA.debugLine="m.Initialize";
_m.Initialize();
 //BA.debugLineNum = 343;BA.debugLine="If 	j.Success Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_j._success /*boolean*/ ) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 344;BA.debugLine="Dim parser As JSONParser";
_parser = new anywheresoftware.b4a.objects.collections.JSONParser();
 //BA.debugLineNum = 346;BA.debugLine="parser.Initialize(j.GetString)";
_parser.Initialize(_j._getstring /*String*/ ());
 //BA.debugLineNum = 348;BA.debugLine="Dim m As Map = parser.NextObject";
_m = new anywheresoftware.b4a.objects.collections.Map();
_m = _parser.NextObject();
 //BA.debugLineNum = 350;BA.debugLine="Log(\"Access Token: \" 	& m.Get(\"access_to";
parent.__c.LogImpl("9244449311","Access Token: "+BA.ObjectToString(_m.Get((Object)("access_token"))),0);
 //BA.debugLineNum = 351;BA.debugLine="Log(\"Refresh Token: \" 	& m.Get(\"refresh_";
parent.__c.LogImpl("9244449312","Refresh Token: "+BA.ObjectToString(_m.Get((Object)("refresh_token"))),0);
 //BA.debugLineNum = 352;BA.debugLine="Log(\"Token Type: \" 		& m.Get(\"token_type";
parent.__c.LogImpl("9244449313","Token Type: "+BA.ObjectToString(_m.Get((Object)("token_type"))),0);
 //BA.debugLineNum = 354;BA.debugLine="j.Release";
_j._release /*String*/ ();
 //BA.debugLineNum = 355;BA.debugLine="Return m";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(_m));return;};
 if (true) break;

case 4:
//C
this.state = -1;
;
 //BA.debugLineNum = 358;BA.debugLine="Log(\"ResponseError. Reason: \" & j.ErrorMe";
parent.__c.LogImpl("9244449319","ResponseError. Reason: "+_j._errormessage /*String*/ +", Response: "+_j._getstring /*String*/ (),0);
 //BA.debugLineNum = 360;BA.debugLine="j.Release";
_j._release /*String*/ ();
 //BA.debugLineNum = 362;BA.debugLine="Return m";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(_m));return;};
 //BA.debugLineNum = 363;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public String  _initialize(anywheresoftware.b4a.BA _ba) throws Exception{
innerInitialize(_ba);
 //BA.debugLineNum = 32;BA.debugLine="Public  Sub Initialize";
 //BA.debugLineNum = 33;BA.debugLine="End Sub";
return "";
}
public anywheresoftware.b4a.keywords.Common.ResumableSubWrapper  _listfiles(String _xfolderpath,boolean _xrecursive) throws Exception{
ResumableSub_ListFiles rsub = new ResumableSub_ListFiles(this,_xfolderpath,_xrecursive);
rsub.resume(ba, null);
return (anywheresoftware.b4a.keywords.Common.ResumableSubWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.keywords.Common.ResumableSubWrapper(), rsub);
}
public static class ResumableSub_ListFiles extends BA.ResumableSub {
public ResumableSub_ListFiles(com.BOBs.BBS.cdropbox parent,String _xfolderpath,boolean _xrecursive) {
this.parent = parent;
this._xfolderpath = _xfolderpath;
this._xrecursive = _xrecursive;
}
com.BOBs.BBS.cdropbox parent;
String _xfolderpath;
boolean _xrecursive;
boolean _success;
anywheresoftware.b4a.objects.collections.List _listfileitems = null;
com.BOBs.BBS.httpjob _j;
String _xurl = "";
anywheresoftware.b4a.objects.collections.Map _mapbody = null;
anywheresoftware.b4a.objects.collections.JSONParser.JSONGenerator _jsongenerator = null;
anywheresoftware.b4a.objects.collections.JSONParser _parser = null;
anywheresoftware.b4a.objects.collections.Map _parsermap = null;
anywheresoftware.b4a.objects.collections.List _entries = null;
anywheresoftware.b4a.objects.collections.Map _entry = null;
String _modified = "";
String _filetype = "";
anywheresoftware.b4a.BA.IterableList group27;
int index27;
int groupLen27;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
{
parent.__c.ReturnFromResumableSub(this,null);return;}
case 0:
//C
this.state = 1;
 //BA.debugLineNum = 371;BA.debugLine="Wait For (EnsureAccessToken) Complete (Succe";
parent.__c.WaitFor("complete", ba, this, parent._ensureaccesstoken());
this.state = 17;
return;
case 17:
//C
this.state = 1;
_success = (Boolean) result[0];
;
 //BA.debugLineNum = 373;BA.debugLine="Dim ListFileItems As List";
_listfileitems = new anywheresoftware.b4a.objects.collections.List();
 //BA.debugLineNum = 375;BA.debugLine="ListFileItems.Initialize";
_listfileitems.Initialize();
 //BA.debugLineNum = 377;BA.debugLine="If 	Success = False Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_success==parent.__c.False) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 378;BA.debugLine="Return ListFileItems";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(_listfileitems));return;};
 if (true) break;

case 4:
//C
this.state = 5;
;
 //BA.debugLineNum = 382;BA.debugLine="Dim j As HttpJob";
_j = new com.BOBs.BBS.httpjob();
 //BA.debugLineNum = 384;BA.debugLine="j.Initialize(\"ListFiles\",  Me)";
_j._initialize /*String*/ (ba,"ListFiles",parent);
 //BA.debugLineNum = 386;BA.debugLine="Dim xUrl As String = $\"${DEFINE_DropBox_Defa";
_xurl = (""+parent.__c.SmartStringFormatter("",(Object)(parent._define_dropbox_default_pathfiles))+"/list_folder");
 //BA.debugLineNum = 388;BA.debugLine="Dim MapBody As Map";
_mapbody = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 390;BA.debugLine="MapBody = CreateMap(\"path\" : xFolderPath, \"recu";
_mapbody = parent.__c.createMap(new Object[] {(Object)("path"),(Object)(_xfolderpath),(Object)("recursive"),(Object)(_xrecursive)});
 //BA.debugLineNum = 392;BA.debugLine="Dim JsonGenerator 	As JSONGenerator";
_jsongenerator = new anywheresoftware.b4a.objects.collections.JSONParser.JSONGenerator();
 //BA.debugLineNum = 394;BA.debugLine="JsonGenerator.Initialize(MapBody)";
_jsongenerator.Initialize(_mapbody);
 //BA.debugLineNum = 396;BA.debugLine="j.PostString(xUrl, JsonGenerator.ToString)";
_j._poststring /*String*/ (_xurl,_jsongenerator.ToString());
 //BA.debugLineNum = 398;BA.debugLine="j.GetRequest.SetHeader(\"Authorization\", \"Bea";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Authorization","Bearer "+parent._accesstoken);
 //BA.debugLineNum = 399;BA.debugLine="j.GetRequest.SetContentType(\"application/jso";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetContentType("application/json");
 //BA.debugLineNum = 401;BA.debugLine="Wait For (j) JobDone(j As HttpJob)";
parent.__c.WaitFor("jobdone", ba, this, (Object)(_j));
this.state = 18;
return;
case 18:
//C
this.state = 5;
_j = (com.BOBs.BBS.httpjob) result[0];
;
 //BA.debugLineNum = 403;BA.debugLine="mLastHTTPCode = j.Response.StatusCode";
parent._mlasthttpcode = _j._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ .getStatusCode();
 //BA.debugLineNum = 405;BA.debugLine="If  j.Success = False Then";
if (true) break;

case 5:
//if
this.state = 8;
if (_j._success /*boolean*/ ==parent.__c.False) { 
this.state = 7;
}if (true) break;

case 7:
//C
this.state = 8;
 //BA.debugLineNum = 406;BA.debugLine="j.Release";
_j._release /*String*/ ();
 //BA.debugLineNum = 408;BA.debugLine="Return ListFileItems";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(_listfileitems));return;};
 if (true) break;

case 8:
//C
this.state = 9;
;
 //BA.debugLineNum = 411;BA.debugLine="Dim parser As JSONParser";
_parser = new anywheresoftware.b4a.objects.collections.JSONParser();
 //BA.debugLineNum = 413;BA.debugLine="parser.Initialize(j.GetString)";
_parser.Initialize(_j._getstring /*String*/ ());
 //BA.debugLineNum = 415;BA.debugLine="Dim ParserMap	As Map 	= parser.NextObject";
_parsermap = new anywheresoftware.b4a.objects.collections.Map();
_parsermap = _parser.NextObject();
 //BA.debugLineNum = 416;BA.debugLine="Dim Entries 	As List = ParserMap.Get(\"entrie";
_entries = new anywheresoftware.b4a.objects.collections.List();
_entries = (anywheresoftware.b4a.objects.collections.List) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.List(), (java.util.List)(_parsermap.Get((Object)("entries"))));
 //BA.debugLineNum = 418;BA.debugLine="For Each Entry As Map In Entries";
if (true) break;

case 9:
//for
this.state = 16;
_entry = new anywheresoftware.b4a.objects.collections.Map();
group27 = _entries;
index27 = 0;
groupLen27 = group27.getSize();
this.state = 19;
if (true) break;

case 19:
//C
this.state = 16;
if (index27 < groupLen27) {
this.state = 11;
_entry = (anywheresoftware.b4a.objects.collections.Map) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.Map(), (java.util.Map)(group27.Get(index27)));}
if (true) break;

case 20:
//C
this.state = 19;
index27++;
if (true) break;

case 11:
//C
this.state = 12;
 //BA.debugLineNum = 419;BA.debugLine="Dim Modified As String = \"\"";
_modified = "";
 //BA.debugLineNum = 420;BA.debugLine="Dim FileType As String = Entry.Get(\".tag";
_filetype = BA.ObjectToString(_entry.Get((Object)(".tag")));
 //BA.debugLineNum = 422;BA.debugLine="If 	Entry.ContainsKey(\"client_modified\")";
if (true) break;

case 12:
//if
this.state = 15;
if (_entry.ContainsKey((Object)("client_modified"))) { 
this.state = 14;
}if (true) break;

case 14:
//C
this.state = 15;
 //BA.debugLineNum = 423;BA.debugLine="Modified = Entry.Get(\"client_modifie";
_modified = BA.ObjectToString(_entry.Get((Object)("client_modified")));
 if (true) break;

case 15:
//C
this.state = 20;
;
 //BA.debugLineNum = 426;BA.debugLine="ListFileItems.Add(ListFiles_CreateItemTy";
_listfileitems.Add((Object)(parent._listfiles_createitemtype(BA.ObjectToString(_entry.Get((Object)("path_display"))),BA.ObjectToString(_entry.Get((Object)("path_display"))),BA.ObjectToBoolean((((_filetype).equals("folder")) ? ((Object)(parent.__c.True)) : ((Object)(parent.__c.False)))),BA.ObjectToLongNumber((((_modified).equals("") == false) ? ((Object)(parent._listfiles_parse_httpdate(_modified))) : ((Object)(0)))))));
 if (true) break;
if (true) break;

case 16:
//C
this.state = -1;
;
 //BA.debugLineNum = 429;BA.debugLine="Return ListFileItems";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(_listfileitems));return;};
 //BA.debugLineNum = 430;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public com.BOBs.BBS.cdropbox._cdropbox_listitemtype  _listfiles_createitemtype(String _xname,String _xhref,boolean _xisdirectory,long _xlastmodified) throws Exception{
com.BOBs.BBS.cdropbox._cdropbox_listitemtype _listitemtype = null;
 //BA.debugLineNum = 432;BA.debugLine="Private Sub ListFiles_CreateItemType(xName As Stri";
 //BA.debugLineNum = 433;BA.debugLine="Dim ListItemType As cDropBox_ListItemType";
_listitemtype = new com.BOBs.BBS.cdropbox._cdropbox_listitemtype();
 //BA.debugLineNum = 435;BA.debugLine="ListItemType.Initialize";
_listitemtype.Initialize();
 //BA.debugLineNum = 436;BA.debugLine="ListItemType.Name			= xName";
_listitemtype.Name /*String*/  = _xname;
 //BA.debugLineNum = 437;BA.debugLine="ListItemType.HRef			= xHRef";
_listitemtype.HRef /*String*/  = _xhref;
 //BA.debugLineNum = 438;BA.debugLine="ListItemType.IsDirectory	= xIsDirectory";
_listitemtype.IsDirectory /*boolean*/  = _xisdirectory;
 //BA.debugLineNum = 439;BA.debugLine="ListItemType.LastModified	= xLastModified";
_listitemtype.LastModified /*long*/  = _xlastmodified;
 //BA.debugLineNum = 441;BA.debugLine="Return ListItemType";
if (true) return _listitemtype;
 //BA.debugLineNum = 442;BA.debugLine="End Sub";
return null;
}
public long  _listfiles_parse_httpdate(String _xhttpdate) throws Exception{
String _xoldformat = "";
long _xdt = 0L;
 //BA.debugLineNum = 449;BA.debugLine="Private Sub ListFiles_Parse_HttpDate(xHttpDate As";
 //BA.debugLineNum = 450;BA.debugLine="Dim xOldFormat 	As String 	= DateTime.DateFo";
_xoldformat = __c.DateTime.getDateFormat();
 //BA.debugLineNum = 451;BA.debugLine="Dim xDT 		As Long		= 0";
_xdt = (long) (0);
 //BA.debugLineNum = 453;BA.debugLine="xHttpDate = xHttpDate.Replace(\"T\", \" \")";
_xhttpdate = _xhttpdate.replace("T"," ");
 //BA.debugLineNum = 454;BA.debugLine="xHttpDate = xHttpDate.Replace(\"Z\", \"\")";
_xhttpdate = _xhttpdate.replace("Z","");
 //BA.debugLineNum = 456;BA.debugLine="DateTime.DateFormat = \"yyyy-MM-dd HH:mm:ss\"";
__c.DateTime.setDateFormat("yyyy-MM-dd HH:mm:ss");
 //BA.debugLineNum = 458;BA.debugLine="Try";
try { //BA.debugLineNum = 459;BA.debugLine="xDT = DateTime.DateParse(xHttpDate)";
_xdt = __c.DateTime.DateParse(_xhttpdate);
 } 
       catch (Exception e9) {
			ba.setLastException(e9); //BA.debugLineNum = 461;BA.debugLine="Log(LastException.Message)";
__c.LogImpl("9244645900",__c.LastException(getActivityBA()).getMessage(),0);
 };
 //BA.debugLineNum = 464;BA.debugLine="DateTime.DateFormat = xOldFormat";
__c.DateTime.setDateFormat(_xoldformat);
 //BA.debugLineNum = 466;BA.debugLine="Return xDT";
if (true) return _xdt;
 //BA.debugLineNum = 467;BA.debugLine="End Sub";
return 0L;
}
public anywheresoftware.b4a.keywords.Common.ResumableSubWrapper  _refreshaccesstoken(String _xappkey,String _xappsecret,String _xrefreshtoken) throws Exception{
ResumableSub_RefreshAccessToken rsub = new ResumableSub_RefreshAccessToken(this,_xappkey,_xappsecret,_xrefreshtoken);
rsub.resume(ba, null);
return (anywheresoftware.b4a.keywords.Common.ResumableSubWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.keywords.Common.ResumableSubWrapper(), rsub);
}
public static class ResumableSub_RefreshAccessToken extends BA.ResumableSub {
public ResumableSub_RefreshAccessToken(com.BOBs.BBS.cdropbox parent,String _xappkey,String _xappsecret,String _xrefreshtoken) {
this.parent = parent;
this._xappkey = _xappkey;
this._xappsecret = _xappsecret;
this._xrefreshtoken = _xrefreshtoken;
}
com.BOBs.BBS.cdropbox parent;
String _xappkey;
String _xappsecret;
String _xrefreshtoken;
com.BOBs.BBS.httpjob _j;
String _postdata = "";
anywheresoftware.b4a.objects.collections.JSONParser _parser = null;
anywheresoftware.b4a.objects.collections.Map _m = null;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
{
parent.__c.ReturnFromResumableSub(this,null);return;}
case 0:
//C
this.state = 1;
 //BA.debugLineNum = 476;BA.debugLine="Dim j As HttpJob";
_j = new com.BOBs.BBS.httpjob();
 //BA.debugLineNum = 478;BA.debugLine="j.Initialize(\"RefreshAccessToken\", Me)";
_j._initialize /*String*/ (ba,"RefreshAccessToken",parent);
 //BA.debugLineNum = 480;BA.debugLine="Dim postData As String = _         			\"grant";
_postdata = "grant_type=refresh_token"+"&refresh_token="+_xrefreshtoken+"&client_id="+_xappkey+"&client_secret="+_xappsecret;
 //BA.debugLineNum = 487;BA.debugLine="j.PostString($\"${DEFINE_DropBox_Default_WebS";
_j._poststring /*String*/ ((""+parent.__c.SmartStringFormatter("",(Object)(parent._define_dropbox_default_website))+"/oauth2/token"),_postdata);
 //BA.debugLineNum = 489;BA.debugLine="j.GetRequest.SetHeader(\"Content-Type\", \"appl";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Content-Type","application/x-www-form-urlencoded");
 //BA.debugLineNum = 491;BA.debugLine="Wait For (j) JobDone(j As HttpJob)";
parent.__c.WaitFor("jobdone", ba, this, (Object)(_j));
this.state = 5;
return;
case 5:
//C
this.state = 1;
_j = (com.BOBs.BBS.httpjob) result[0];
;
 //BA.debugLineNum = 493;BA.debugLine="If 	j.Success Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_j._success /*boolean*/ ) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 494;BA.debugLine="Dim parser As JSONParser";
_parser = new anywheresoftware.b4a.objects.collections.JSONParser();
 //BA.debugLineNum = 496;BA.debugLine="parser.Initialize(j.GetString)";
_parser.Initialize(_j._getstring /*String*/ ());
 //BA.debugLineNum = 498;BA.debugLine="Dim m As Map = parser.NextObject";
_m = new anywheresoftware.b4a.objects.collections.Map();
_m = _parser.NextObject();
 //BA.debugLineNum = 500;BA.debugLine="AccessToken = m.Get(\"access_token\")";
parent._accesstoken = BA.ObjectToString(_m.Get((Object)("access_token")));
 //BA.debugLineNum = 502;BA.debugLine="j.Release";
_j._release /*String*/ ();
 //BA.debugLineNum = 504;BA.debugLine="Return AccessToken";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent._accesstoken));return;};
 if (true) break;

case 4:
//C
this.state = -1;
;
 //BA.debugLineNum = 507;BA.debugLine="Log(\"Error refreshing token: \" & j.GetStr";
parent.__c.LogImpl("9244711456","Error refreshing token: "+_j._getstring /*String*/ (),0);
 //BA.debugLineNum = 508;BA.debugLine="j.Release";
_j._release /*String*/ ();
 //BA.debugLineNum = 509;BA.debugLine="Return \"\"";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(""));return;};
 //BA.debugLineNum = 510;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public String  _saveaccesstoken(String _xtoken) throws Exception{
 //BA.debugLineNum = 618;BA.debugLine="Private Sub SaveAccessToken(xToken As String)";
 //BA.debugLineNum = 619;BA.debugLine="Try";
try { //BA.debugLineNum = 621;BA.debugLine="LogColor(\"Saving New Token\", Colors.Red)";
__c.LogImpl("9244973571","Saving New Token",__c.Colors.Red);
 //BA.debugLineNum = 625;BA.debugLine="File.WriteString(File.DirInternal, DEFIN";
__c.File.WriteString(__c.File.getDirInternal(),_define_dropbox_token_fn,_xtoken);
 } 
       catch (Exception e5) {
			ba.setLastException(e5); //BA.debugLineNum = 632;BA.debugLine="Log(\"Error saving token\")";
__c.LogImpl("9244973582","Error saving token",0);
 };
 //BA.debugLineNum = 634;BA.debugLine="End Sub";
return "";
}
public String  _setauthorization(String _xappkey,String _xappsecret,String _xrefreshtoken) throws Exception{
 //BA.debugLineNum = 514;BA.debugLine="Public  Sub SetAuthorization(xAppKey As String, xA";
 //BA.debugLineNum = 515;BA.debugLine="RefreshToken    = xRefreshToken";
_refreshtoken = _xrefreshtoken;
 //BA.debugLineNum = 516;BA.debugLine="AppKey  	    = xAppKey";
_appkey = _xappkey;
 //BA.debugLineNum = 517;BA.debugLine="AppSecret   	= xAppSecret";
_appsecret = _xappsecret;
 //BA.debugLineNum = 521;BA.debugLine="If 	File.Exists(File.DirInternal, DEFINE_Dro";
if (__c.File.Exists(__c.File.getDirInternal(),_define_dropbox_token_fn)) { 
 //BA.debugLineNum = 522;BA.debugLine="AccessToken = File.ReadString(File.DirIn";
_accesstoken = __c.File.ReadString(__c.File.getDirInternal(),_define_dropbox_token_fn);
 }else {
 //BA.debugLineNum = 531;BA.debugLine="AccessToken = \"\"";
_accesstoken = "";
 };
 //BA.debugLineNum = 533;BA.debugLine="End Sub";
return "";
}
public anywheresoftware.b4a.keywords.Common.ResumableSubWrapper  _uploadfile(String _xlocalpath,String _xlocalfile,String _xremotepath) throws Exception{
ResumableSub_UploadFile rsub = new ResumableSub_UploadFile(this,_xlocalpath,_xlocalfile,_xremotepath);
rsub.resume(ba, null);
return (anywheresoftware.b4a.keywords.Common.ResumableSubWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.keywords.Common.ResumableSubWrapper(), rsub);
}
public static class ResumableSub_UploadFile extends BA.ResumableSub {
public ResumableSub_UploadFile(com.BOBs.BBS.cdropbox parent,String _xlocalpath,String _xlocalfile,String _xremotepath) {
this.parent = parent;
this._xlocalpath = _xlocalpath;
this._xlocalfile = _xlocalfile;
this._xremotepath = _xremotepath;
}
com.BOBs.BBS.cdropbox parent;
String _xlocalpath;
String _xlocalfile;
String _xremotepath;
boolean _success;
com.BOBs.BBS.httpjob _j;
String _xurl = "";
String _xargs = "";
byte[] _xbytes = null;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
{
parent.__c.ReturnFromResumableSub(this,null);return;}
case 0:
//C
this.state = 1;
 //BA.debugLineNum = 541;BA.debugLine="Wait For (EnsureAccessToken) Complete (Succe";
parent.__c.WaitFor("complete", ba, this, parent._ensureaccesstoken());
this.state = 9;
return;
case 9:
//C
this.state = 1;
_success = (Boolean) result[0];
;
 //BA.debugLineNum = 543;BA.debugLine="If  Success = False Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_success==parent.__c.False) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 544;BA.debugLine="Return False";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.False));return;};
 if (true) break;

case 4:
//C
this.state = 5;
;
 //BA.debugLineNum = 547;BA.debugLine="Dim j As HttpJob";
_j = new com.BOBs.BBS.httpjob();
 //BA.debugLineNum = 549;BA.debugLine="j.Initialize(\"Upload\",  Me)";
_j._initialize /*String*/ (ba,"Upload",parent);
 //BA.debugLineNum = 551;BA.debugLine="Dim xUrl As String = $\"${DEFINE_DropBox_Defa";
_xurl = (""+parent.__c.SmartStringFormatter("",(Object)(parent._define_dropbox_default_content_pathfiles))+"/upload");
 //BA.debugLineNum = 552;BA.debugLine="Dim xArgs As String = \"{\"\"path\"\": \"\"\" & xRem";
_xargs = "{\"path\": \""+_xremotepath+"\",\"mode\": \"overwrite\"}";
 //BA.debugLineNum = 557;BA.debugLine="Dim xBytes() As Byte = File.ReadBytes(xLocal";
_xbytes = parent.__c.File.ReadBytes(_xlocalpath,_xlocalfile);
 //BA.debugLineNum = 559;BA.debugLine="j.PostBytes(xUrl, xBytes)";
_j._postbytes /*String*/ (_xurl,_xbytes);
 //BA.debugLineNum = 560;BA.debugLine="j.GetRequest.SetHeader(\"Authorization\", \"Bea";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Authorization","Bearer "+parent._accesstoken);
 //BA.debugLineNum = 561;BA.debugLine="j.GetRequest.SetHeader(\"Dropbox-API-Arg\", xA";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Dropbox-API-Arg",_xargs);
 //BA.debugLineNum = 562;BA.debugLine="j.GetRequest.SetContentType(\"application/oct";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetContentType("application/octet-stream");
 //BA.debugLineNum = 565;BA.debugLine="Wait For (j) JobDone(j As HttpJob)";
parent.__c.WaitFor("jobdone", ba, this, (Object)(_j));
this.state = 10;
return;
case 10:
//C
this.state = 5;
_j = (com.BOBs.BBS.httpjob) result[0];
;
 //BA.debugLineNum = 567;BA.debugLine="mLastHTTPCode = j.Response.StatusCode";
parent._mlasthttpcode = _j._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ .getStatusCode();
 //BA.debugLineNum = 569;BA.debugLine="If j.Success Then";
if (true) break;

case 5:
//if
this.state = 8;
if (_j._success /*boolean*/ ) { 
this.state = 7;
}if (true) break;

case 7:
//C
this.state = 8;
 //BA.debugLineNum = 570;BA.debugLine="Return True";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.True));return;};
 if (true) break;

case 8:
//C
this.state = -1;
;
 //BA.debugLineNum = 573;BA.debugLine="Log(\"Upload Error: \" & j.ErrorMessage)";
parent.__c.LogImpl("9244842529","Upload Error: "+_j._errormessage /*String*/ ,0);
 //BA.debugLineNum = 574;BA.debugLine="Return False";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.False));return;};
 //BA.debugLineNum = 575;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public anywheresoftware.b4a.keywords.Common.ResumableSubWrapper  _uploadstream(byte[] _xbytes,String _xremotepath) throws Exception{
ResumableSub_UploadStream rsub = new ResumableSub_UploadStream(this,_xbytes,_xremotepath);
rsub.resume(ba, null);
return (anywheresoftware.b4a.keywords.Common.ResumableSubWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.keywords.Common.ResumableSubWrapper(), rsub);
}
public static class ResumableSub_UploadStream extends BA.ResumableSub {
public ResumableSub_UploadStream(com.BOBs.BBS.cdropbox parent,byte[] _xbytes,String _xremotepath) {
this.parent = parent;
this._xbytes = _xbytes;
this._xremotepath = _xremotepath;
}
com.BOBs.BBS.cdropbox parent;
byte[] _xbytes;
String _xremotepath;
boolean _success;
com.BOBs.BBS.httpjob _j;
String _xurl = "";
String _xargs = "";

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
{
parent.__c.ReturnFromResumableSub(this,null);return;}
case 0:
//C
this.state = 1;
 //BA.debugLineNum = 583;BA.debugLine="Wait For (EnsureAccessToken) Complete (Succe";
parent.__c.WaitFor("complete", ba, this, parent._ensureaccesstoken());
this.state = 9;
return;
case 9:
//C
this.state = 1;
_success = (Boolean) result[0];
;
 //BA.debugLineNum = 585;BA.debugLine="If  Success = False Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_success==parent.__c.False) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 586;BA.debugLine="Return False";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.False));return;};
 if (true) break;

case 4:
//C
this.state = 5;
;
 //BA.debugLineNum = 589;BA.debugLine="Dim j As HttpJob";
_j = new com.BOBs.BBS.httpjob();
 //BA.debugLineNum = 591;BA.debugLine="j.Initialize(\"Upload\",  Me)";
_j._initialize /*String*/ (ba,"Upload",parent);
 //BA.debugLineNum = 593;BA.debugLine="Dim xUrl As String = $\"${DEFINE_DropBox_Defa";
_xurl = (""+parent.__c.SmartStringFormatter("",(Object)(parent._define_dropbox_default_content_pathfiles))+"/upload");
 //BA.debugLineNum = 594;BA.debugLine="Dim xArgs As String = \"{\"\"path\"\": \"\"\" & xRem";
_xargs = "{\"path\": \""+_xremotepath+"\",\"mode\": \"overwrite\"}";
 //BA.debugLineNum = 599;BA.debugLine="j.PostBytes(xUrl, xBytes)";
_j._postbytes /*String*/ (_xurl,_xbytes);
 //BA.debugLineNum = 600;BA.debugLine="j.GetRequest.SetHeader(\"Authorization\", \"Bea";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Authorization","Bearer "+parent._accesstoken);
 //BA.debugLineNum = 601;BA.debugLine="j.GetRequest.SetHeader(\"Dropbox-API-Arg\", xA";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Dropbox-API-Arg",_xargs);
 //BA.debugLineNum = 602;BA.debugLine="j.GetRequest.SetContentType(\"application/oct";
_j._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetContentType("application/octet-stream");
 //BA.debugLineNum = 605;BA.debugLine="Wait For (j) JobDone(j As HttpJob)";
parent.__c.WaitFor("jobdone", ba, this, (Object)(_j));
this.state = 10;
return;
case 10:
//C
this.state = 5;
_j = (com.BOBs.BBS.httpjob) result[0];
;
 //BA.debugLineNum = 607;BA.debugLine="mLastHTTPCode = j.Response.StatusCode";
parent._mlasthttpcode = _j._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ .getStatusCode();
 //BA.debugLineNum = 609;BA.debugLine="If j.Success Then";
if (true) break;

case 5:
//if
this.state = 8;
if (_j._success /*boolean*/ ) { 
this.state = 7;
}if (true) break;

case 7:
//C
this.state = 8;
 //BA.debugLineNum = 610;BA.debugLine="Return True";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.True));return;};
 if (true) break;

case 8:
//C
this.state = -1;
;
 //BA.debugLineNum = 613;BA.debugLine="Log(\"Upload Error: \" & j.ErrorMessage)";
parent.__c.LogImpl("9244908063","Upload Error: "+_j._errormessage /*String*/ ,0);
 //BA.debugLineNum = 614;BA.debugLine="Return False";
if (true) {
parent.__c.ReturnFromResumableSub(this,(Object)(parent.__c.False));return;};
 //BA.debugLineNum = 615;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public Object callSub(String sub, Object sender, Object[] args) throws Exception {
BA.senderHolder.set(sender);
return BA.SubDelegator.SubNotFound;
}
}
