main.py 125 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068
  1. import os
  2. import random
  3. import string
  4. import traceback
  5. import shutil
  6. import uuid
  7. from flask import Flask, request
  8. base_directory = "/Users/maronakins/Documents"
  9. app = Flask(__name__)
  10. app.base_project = {
  11. "android": base_directory + "/EmbedFeatures/NexilisSampleCode",
  12. "android_flutter": base_directory + "/EmbedFeatures/NexilisSampleCodeFlutter-Android",
  13. "android_ionic": base_directory + "/EmbedFeatures/NexilisSampleCodeIonic-Android",
  14. "android_react": base_directory + "/EmbedFeatures/NexilisSampleCodeReact-Android",
  15. "ios": base_directory + "/EmbedFeatures/NexilisSampleCode-iOS",
  16. "ios_flutter": base_directory + "/EmbedFeatures/NexilisSampleCodeFlutter-iOS",
  17. "ios_ionic": base_directory + "/EmbedFeatures/NexilisSampleCodeIonic-iOS",
  18. "ios_react": base_directory + "/EmbedFeatures/NexilisSampleCodeReact-iOS"
  19. }
  20. app.temp_folder = base_directory + "/EmbedFeatures/BuildExample"
  21. app.zip_folder = base_directory + "/EmbedFeatures/uploads"
  22. # app.ssl = ('/usr/src/app/ssl/STAR_newuniverse_io.crt', '/usr/src/app/ssl/STAR_nexilis.key')
  23. app.ssl = None
  24. app.verbose = True
  25. def vprint(*data):
  26. if app.verbose:
  27. print(*data)
  28. def indented_str(n, s, line=True, spaces=4) -> str:
  29. return " " * n * spaces + s + os.linesep if line else ""
  30. def create_folder(platform, uid):
  31. path = os.path.join(app.temp_folder, uid)
  32. if not os.path.exists(path):
  33. os.mkdir(path)
  34. else:
  35. shutil.rmtree(path)
  36. os.mkdir(path)
  37. vprint(path)
  38. base_project = app.base_project[platform]
  39. base_project_name = os.path.basename(base_project)
  40. path_dest = os.path.join(path, base_project_name)
  41. if not os.path.exists(path_dest):
  42. shutil.copytree(base_project, path_dest)
  43. return path_dest
  44. def write_android_manifest(manifest_path: str, features: dict, security: dict):
  45. with open(manifest_path, "r") as f:
  46. lines = f.readlines()
  47. with open(manifest_path, "w") as f:
  48. for line in lines:
  49. if "<!-- FEATURES -->" in line:
  50. if features["sms"]["status"]:
  51. f.write(indented_str(1, '<!-- use SMS permission -->'))
  52. f.write(indented_str(1, '<uses-permission android:name="android.permission.RECEIVE_SMS" />'))
  53. f.write(indented_str(1, '<uses-permission android:name="android.permission.SEND_SMS" />'))
  54. f.write(indented_str(1, '<uses-permission android:name="android.permission.READ_SMS" />'))
  55. f.write(indented_str(1, '<uses-permission android:name="android.permission.WRITE_SMS" />'))
  56. else:
  57. f.write(indented_str(1, '<!-- use SMS permission -->'))
  58. f.write(indented_str(1, '<!-- <uses-permission android:name="android.permission.RECEIVE_SMS" /> -->'))
  59. f.write(indented_str(1, '<!-- <uses-permission android:name="android.permission.SEND_SMS" /> -->'))
  60. f.write(indented_str(1, '<!-- <uses-permission android:name="android.permission.READ_SMS" /> -->'))
  61. f.write(indented_str(1, '<!-- <uses-permission android:name="android.permission.WRITE_SMS" /> -->'))
  62. elif "<!-- SECURITY -->" in line:
  63. if security["malware"] or security["side_load"] :
  64. f.write(indented_str(1, '<!-- use Malware Detection & Sideload App permission -->'))
  65. f.write(indented_str(1, '<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />'))
  66. else:
  67. f.write(indented_str(1, '<!-- use Malware Detection & Sideload App permission -->'))
  68. f.write(indented_str(1, '<!-- <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> -->'))
  69. else:
  70. f.write(line)
  71. def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict, security: dict):
  72. if platform == "android":
  73. main_act_path = os.path.join(path_dest,
  74. "app/src/main/java/com/example/nexilissamplecodeburger/MainActivity.java")
  75. xml_menu_path = os.path.join(path_dest, "app/src/main/res/menu/menu_main.xml")
  76. manifest_path = os.path.join(path_dest, "app/src/main/AndroidManifest.xml")
  77. with open(main_act_path, "r") as f:
  78. lines = f.readlines()
  79. with open(main_act_path, "w") as f:
  80. for line in lines:
  81. if "//FEATURES" in line:
  82. f.write(indented_str(2, "if (id == R.id.action_settings) {"))
  83. f.write(indented_str(3, "API.openSettings();"))
  84. f.write(indented_str(3, "return true;"))
  85. f.write(indented_str(2, "}"))
  86. f.write(indented_str(2, "if (id == R.id.action_profile) {"))
  87. f.write(indented_str(3, "API.openProfile();"))
  88. f.write(indented_str(3, "return true;"))
  89. f.write(indented_str(2, "}"))
  90. if features["cc"]["status"]:
  91. f.write(indented_str(2, "if (id == R.id.action_cc) {"))
  92. f.write(indented_str(3, "API.openContactCenter();"))
  93. f.write(indented_str(3, "return true;"))
  94. f.write(indented_str(2, "}"))
  95. else:
  96. f.write(indented_str(2, "// if (id == R.id.action_cc) {"))
  97. f.write(indented_str(3, "// API.openContactCenter();"))
  98. f.write(indented_str(3, "// return true;"))
  99. f.write(indented_str(2, "// }"))
  100. if features["nc"]["status"]:
  101. f.write(indented_str(2, "if (id == R.id.action_nc) {"))
  102. f.write(indented_str(3, "API.openNotificationCenter();"))
  103. f.write(indented_str(3, "return true;"))
  104. f.write(indented_str(2, "}"))
  105. else:
  106. f.write(indented_str(2, "// if (id == R.id.action_nc) {"))
  107. f.write(indented_str(3, "// API.openNotificationCenter();"))
  108. f.write(indented_str(3, "// return true;"))
  109. f.write(indented_str(2, "// }"))
  110. if features["im"]["status"]:
  111. f.write(indented_str(2, "if (id == R.id.action_chats) {"))
  112. f.write(indented_str(3, "API.openChat();"))
  113. f.write(indented_str(3, "return true;"))
  114. f.write(indented_str(2, "}"))
  115. else:
  116. f.write(indented_str(2, "// if (id == R.id.action_chats) {"))
  117. f.write(indented_str(3, "// API.openChat();"))
  118. f.write(indented_str(3, "// return true;"))
  119. f.write(indented_str(2, "// }"))
  120. if features["call"]["status"]:
  121. f.write(indented_str(2, "if (id == R.id.action_call) {"))
  122. f.write(indented_str(3, "API.openCall();"))
  123. f.write(indented_str(3, "return true;"))
  124. f.write(indented_str(2, "}"))
  125. else:
  126. f.write(indented_str(2, "// if (id == R.id.action_call) {"))
  127. f.write(indented_str(3, "// API.openCall();"))
  128. f.write(indented_str(3, "// return true;"))
  129. f.write(indented_str(2, "// }"))
  130. if features["ls"]["status"]:
  131. f.write(indented_str(2, "if (id == R.id.action_ls) {"))
  132. f.write(indented_str(3, "API.openOptionsStreaming();"))
  133. f.write(indented_str(3, "return true;"))
  134. f.write(indented_str(2, "}"))
  135. else:
  136. f.write(indented_str(2, "// if (id == R.id.action_ls) {"))
  137. f.write(indented_str(3, "// API.openOptionsStreaming();"))
  138. f.write(indented_str(3, "// return true;"))
  139. f.write(indented_str(2, "// }"))
  140. if security["secure_folder"]:
  141. f.write(indented_str(2, "if (id == R.id.action_sf) {"))
  142. f.write(indented_str(3, "API.openSecureFolder();"))
  143. f.write(indented_str(3, "return true;"))
  144. f.write(indented_str(2, "}"))
  145. else:
  146. f.write(indented_str(2, "// if (id == R.id.action_sf) {"))
  147. f.write(indented_str(3, "// API.openSecureFolder();"))
  148. f.write(indented_str(3, "// return true;"))
  149. f.write(indented_str(2, "// }"))
  150. elif "//SECURITY" in line:
  151. if security["show_security"]:
  152. f.write(indented_str(2, "API.setShowSecurityShieldDialog(true);"))
  153. f.write(os.linesep)
  154. else:
  155. f.write(indented_str(2, "// API.setShowSecurityShieldDialog(true);"))
  156. f.write(os.linesep)
  157. if security["emulator"]:
  158. f.write(indented_str(2, "API.setCheckEmulator(true);"))
  159. f.write(os.linesep)
  160. else:
  161. f.write(indented_str(2, "// API.setCheckEmulator(true);"))
  162. f.write(os.linesep)
  163. if security["debug"]:
  164. f.write(indented_str(2, "API.setCheckAdb(true);"))
  165. f.write(os.linesep)
  166. else:
  167. f.write(indented_str(2, "// API.setCheckAdb(true);"))
  168. f.write(os.linesep)
  169. if security["sim_swap"]:
  170. f.write(indented_str(2, "API.setCheckSimSwap(true);"))
  171. f.write(os.linesep)
  172. else:
  173. f.write(indented_str(2, "// API.setCheckSimSwap(true);"))
  174. f.write(os.linesep)
  175. if security["malware"]:
  176. f.write(indented_str(2, "API.setCheckMalware(true);"))
  177. f.write(os.linesep)
  178. else:
  179. f.write(indented_str(2, "// API.setCheckMalware(true);"))
  180. f.write(os.linesep)
  181. if security["capture"]:
  182. f.write(indented_str(2, "API.setPreventScreenCapture(true);"))
  183. f.write(os.linesep)
  184. else:
  185. f.write(indented_str(2, "// API.setPreventScreenCapture(true);"))
  186. f.write(os.linesep)
  187. if security["call_forwarding"]:
  188. f.write(indented_str(2, "API.setCheckCallForwarding(true);"))
  189. f.write(os.linesep)
  190. else:
  191. f.write(indented_str(2, "// API.setCheckCallForwarding(true);"))
  192. f.write(os.linesep)
  193. if security["screen_share"]:
  194. f.write(indented_str(2, "API.setCheckScreenCasting(true);"))
  195. f.write(os.linesep)
  196. else:
  197. f.write(indented_str(2, "// API.setCheckScreenCasting(true);"))
  198. f.write(os.linesep)
  199. if security["side_load"]:
  200. f.write(indented_str(2, "API.setCheckSideLoadedApp(true);"))
  201. f.write(os.linesep)
  202. else:
  203. f.write(indented_str(2, "// API.setCheckSideLoadedApp(true);"))
  204. f.write(os.linesep)
  205. if security["key_logger"]:
  206. f.write(indented_str(2, "API.setPreventKeylogger(true);"))
  207. f.write(os.linesep)
  208. else:
  209. f.write(indented_str(2, "// API.setPreventKeylogger(true);"))
  210. f.write(os.linesep)
  211. elif "//SMS" in line:
  212. if features["sms"]["status"]:
  213. f.write(indented_str(2, "API.setEnabledSMS(true);"))
  214. else:
  215. f.write(indented_str(2, "// API.setEnabledSMS(true);"))
  216. elif "//EMAIL" in line:
  217. if features["email"]["status"]:
  218. f.write(indented_str(2, "API.setEnabledEmail(true);"))
  219. else:
  220. f.write(indented_str(2, "// API.setEnabledEmail(true);"))
  221. elif "//SMARTBOT" in line:
  222. if features["smartbot"]["status"]:
  223. f.write(indented_str(2, "API.setEnabledSmartBot(true);"))
  224. else:
  225. f.write(indented_str(2, "// API.setEnabledSmartBot(true);"))
  226. elif "//BREAK" in line:
  227. if mode == "floating":
  228. f.write("}")
  229. break
  230. else:
  231. f.write(indented_str(0,""))
  232. elif "//FLOATING" in line:
  233. if mode == "floating":
  234. f.write(indented_str(6, "ArrayList<FloatingButton> fb = new ArrayList<>();"))
  235. if features["cc"]["status"]:
  236. f.write(indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
  237. else:
  238. f.write(indented_str(6,
  239. '// fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
  240. if features["nc"]["status"]:
  241. f.write(indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
  242. else:
  243. f.write(indented_str(6,
  244. '// fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
  245. if features["im"]["status"]:
  246. f.write(
  247. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
  248. else:
  249. f.write(indented_str(6,
  250. '// fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
  251. if features["call"]["status"]:
  252. f.write(
  253. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
  254. else:
  255. f.write(indented_str(6,
  256. '// fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
  257. if features["ls"]["status"]:
  258. f.write(
  259. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
  260. else:
  261. f.write(indented_str(6,
  262. '// fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
  263. if security["secure_folder"]:
  264. f.write(
  265. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));'))
  266. else:
  267. f.write(indented_str(6,
  268. '// fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));'))
  269. f.write(indented_str(6,
  270. 'API.configureFloating(fb);'))
  271. else:
  272. f.write(indented_str(0, ""))
  273. elif "API.connect" in line:
  274. replaced = line
  275. if app_id:
  276. replaced = replaced.replace('***REPLACE***WITH***YOUR***APPLICATION***NAME***', app_id)
  277. if mode == "floating":
  278. replaced = replaced.replace("0", "1")
  279. f.write(replaced)
  280. else:
  281. f.write(line)
  282. with open(xml_menu_path, "r") as f:
  283. lines = f.readlines()
  284. with open(xml_menu_path, "w") as f:
  285. for line in lines:
  286. if "<!-- FEATURES -->" in line:
  287. n = 100
  288. f.write(indented_str(1, "<item"))
  289. f.write(indented_str(2, 'android:id="@+id/action_settings"'))
  290. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  291. f.write(indented_str(2, 'android:title="Settings"'))
  292. f.write(indented_str(2, 'app:showAsAction="never" />'))
  293. n = n + 1
  294. f.write(indented_str(1, "<item"))
  295. f.write(indented_str(2, 'android:id="@+id/action_profile"'))
  296. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  297. f.write(indented_str(2, 'android:title="Profile"'))
  298. f.write(indented_str(2, 'app:showAsAction="never" />'))
  299. n = n + 1
  300. if features["cc"]["status"]:
  301. f.write(indented_str(1, "<item"))
  302. f.write(indented_str(2, 'android:id="@+id/action_cc"'))
  303. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  304. f.write(indented_str(2, 'android:title="Contact Center"'))
  305. f.write(indented_str(2, 'app:showAsAction="never" />'))
  306. n = n + 1
  307. else:
  308. f.write(indented_str(1, "<!-- <item"))
  309. f.write(indented_str(2, 'android:id="@+id/action_cc"'))
  310. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  311. f.write(indented_str(2, 'android:title="Contact Center"'))
  312. f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
  313. n = n + 1
  314. if features["nc"]["status"]:
  315. f.write(indented_str(1, "<item"))
  316. f.write(indented_str(2, 'android:id="@+id/action_nc"'))
  317. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  318. f.write(indented_str(2, 'android:title="Notification Center"'))
  319. f.write(indented_str(2, 'app:showAsAction="never" />'))
  320. n = n + 1
  321. else:
  322. f.write(indented_str(1, "<!-- <item"))
  323. f.write(indented_str(2, 'android:id="@+id/action_nc"'))
  324. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  325. f.write(indented_str(2, 'android:title="Notification Center"'))
  326. f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
  327. n = n + 1
  328. if features["im"]["status"]:
  329. f.write(indented_str(1, "<item"))
  330. f.write(indented_str(2, 'android:id="@+id/action_chats"'))
  331. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  332. f.write(indented_str(2, 'android:title="Instant Messaging"'))
  333. f.write(indented_str(2, 'app:showAsAction="never" />'))
  334. n = n + 1
  335. else:
  336. f.write(indented_str(1, "<!-- <item"))
  337. f.write(indented_str(2, 'android:id="@+id/action_chats"'))
  338. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  339. f.write(indented_str(2, 'android:title="Instant Messaging"'))
  340. f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
  341. n = n + 1
  342. if features["call"]["status"]:
  343. f.write(indented_str(1, "<item"))
  344. f.write(indented_str(2, 'android:id="@+id/action_call"'))
  345. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  346. f.write(indented_str(2, 'android:title="Call"'))
  347. f.write(indented_str(2, 'app:showAsAction="never" />'))
  348. n = n + 1
  349. else:
  350. f.write(indented_str(1, "<!-- <item"))
  351. f.write(indented_str(2, 'android:id="@+id/action_call"'))
  352. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  353. f.write(indented_str(2, 'android:title="Call"'))
  354. f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
  355. n = n + 1
  356. if features["ls"]["status"]:
  357. f.write(indented_str(1, "<item"))
  358. f.write(indented_str(2, 'android:id="@+id/action_ls"'))
  359. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  360. f.write(indented_str(2, 'android:title="Streaming"'))
  361. f.write(indented_str(2, 'app:showAsAction="never" />'))
  362. n = n + 1
  363. else:
  364. f.write(indented_str(1, "<!-- <item"))
  365. f.write(indented_str(2, 'android:id="@+id/action_ls"'))
  366. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  367. f.write(indented_str(2, 'android:title="Streaming"'))
  368. f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
  369. n = n + 1
  370. if security["secure_folder"]:
  371. f.write(indented_str(1, "<item"))
  372. f.write(indented_str(2, 'android:id="@+id/action_sf"'))
  373. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  374. f.write(indented_str(2, 'android:title="Secure Folder"'))
  375. f.write(indented_str(2, 'app:showAsAction="never" />'))
  376. n = n + 1
  377. else:
  378. f.write(indented_str(1, "<!-- <item"))
  379. f.write(indented_str(2, 'android:id="@+id/action_sf"'))
  380. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  381. f.write(indented_str(2, 'android:title="Secure Folder"'))
  382. f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
  383. n = n + 1
  384. else:
  385. f.write(line)
  386. write_android_manifest(manifest_path, features, security)
  387. elif platform == "android_flutter":
  388. main_act_path = os.path.join(path_dest, "lib/main.dart")
  389. main_act_android = os.path.join(path_dest, "android/app/src/main/java/com/example/paliolitesamplecodeflutter/MainActivity.java")
  390. manifest_path = os.path.join(path_dest, "android/app/src/main/AndroidManifest.xml")
  391. with open(main_act_path, "r") as f:
  392. lines = f.readlines()
  393. with open(main_act_path, "w") as f:
  394. features_str = []
  395. for line in lines:
  396. if "'Features List'" in line:
  397. features_str.append("'Settings'")
  398. features_str.append("'Profile'")
  399. if features["cc"]["status"]:
  400. features_str.append("'Contact Center'")
  401. else:
  402. features_str.append("// 'Contact Center'")
  403. if features["nc"]["status"]:
  404. features_str.append("'Notification Center'")
  405. else:
  406. features_str.append("// 'Notification Center'")
  407. if features["im"]["status"]:
  408. features_str.append("'Instant Messaging'")
  409. else:
  410. features_str.append("// 'Instant Messaging'")
  411. if features["call"]["status"]:
  412. features_str.append("'Call'")
  413. else:
  414. features_str.append("// 'Call'")
  415. if features["ls"]["status"]:
  416. features_str.append("'Streaming'")
  417. else:
  418. features_str.append("// 'Streaming'")
  419. if security["secure_folder"]:
  420. features_str.append("'Secure Folder'")
  421. else:
  422. features_str.append("// 'Secure Folder'")
  423. for feature_str in features_str:
  424. f.write(indented_str(8, f"{feature_str},", spaces=2))
  425. elif "//FEATURES" in line:
  426. f.write(indented_str(3, 'case "Settings":', spaces=2))
  427. f.write(indented_str(4, 'nativeChannel.invokeMethod("openSettings");', spaces=2))
  428. f.write(indented_str(4, "break;", spaces=2))
  429. f.write(indented_str(3, 'case "Profile":', spaces=2))
  430. f.write(indented_str(4, 'nativeChannel.invokeMethod("openProfile");', spaces=2))
  431. f.write(indented_str(4, "break;", spaces=2))
  432. if features["cc"]["status"]:
  433. f.write(indented_str(3, 'case "Contact Center":', spaces=2))
  434. f.write(indented_str(4, 'nativeChannel.invokeMethod("openContactCenter");', spaces=2))
  435. f.write(indented_str(4, "break;", spaces=2))
  436. else:
  437. f.write(indented_str(3, '// case "Contact Center":', spaces=2))
  438. f.write(indented_str(4, '// nativeChannel.invokeMethod("openContactCenter");', spaces=2))
  439. f.write(indented_str(4, "// break;", spaces=2))
  440. if features["nc"]["status"]:
  441. f.write(indented_str(3, 'case "Notification Center":', spaces=2))
  442. f.write(indented_str(4, 'nativeChannel.invokeMethod("openNotificationCenter");', spaces=2))
  443. f.write(indented_str(4, "break;", spaces=2))
  444. else:
  445. f.write(indented_str(3, '// case "Notification Center":', spaces=2))
  446. f.write(indented_str(4, '// nativeChannel.invokeMethod("openNotificationCenter");', spaces=2))
  447. f.write(indented_str(4, "// break;", spaces=2))
  448. if features["im"]["status"]:
  449. f.write(indented_str(3, 'case "Instant Messaging":', spaces=2))
  450. f.write(indented_str(4, 'nativeChannel.invokeMethod("openInstantMessaging");', spaces=2))
  451. f.write(indented_str(4, "break;", spaces=2))
  452. else:
  453. f.write(indented_str(3, '// case "Instant Messaging":', spaces=2))
  454. f.write(indented_str(4, '// nativeChannel.invokeMethod("openInstantMessaging");', spaces=2))
  455. f.write(indented_str(4, "// break;", spaces=2))
  456. if features["call"]["status"]:
  457. f.write(indented_str(3, 'case "Call":', spaces=2))
  458. f.write(indented_str(4, 'nativeChannel.invokeMethod("openCall");', spaces=2))
  459. f.write(indented_str(4, "break;", spaces=2))
  460. else:
  461. f.write(indented_str(3, '// case "Call":', spaces=2))
  462. f.write(indented_str(4, '// nativeChannel.invokeMethod("openCall");', spaces=2))
  463. f.write(indented_str(4, "// break;", spaces=2))
  464. if features["ls"]["status"]:
  465. f.write(indented_str(3, 'case "Streaming":', spaces=2))
  466. f.write(indented_str(4, 'nativeChannel.invokeMethod("openStreaming");', spaces=2))
  467. f.write(indented_str(4, "break;", spaces=2))
  468. else:
  469. f.write(indented_str(3, '// case "Streaming":', spaces=2))
  470. f.write(indented_str(4, '// nativeChannel.invokeMethod("openStreaming");', spaces=2))
  471. f.write(indented_str(4, "// break;", spaces=2))
  472. if security["secure_folder"]:
  473. f.write(indented_str(3, 'case "Secure Folder":', spaces=2))
  474. f.write(indented_str(4, 'nativeChannel.invokeMethod("openSecureFolder");', spaces=2))
  475. f.write(indented_str(4, "break;", spaces=2))
  476. else:
  477. f.write(indented_str(3, '// case "Secure Folder":', spaces=2))
  478. f.write(indented_str(4, '// nativeChannel.invokeMethod("openSecureFolder");', spaces=2))
  479. f.write(indented_str(4, "// break;", spaces=2))
  480. else:
  481. f.write(line)
  482. with open(main_act_android, "r") as f:
  483. lines = f.readlines()
  484. with open(main_act_android, "w") as f:
  485. for line in lines:
  486. if "//SECURITY" in line:
  487. if security["show_security"]:
  488. f.write(indented_str(2, "API.setShowSecurityShieldDialog(true);"))
  489. f.write(os.linesep)
  490. else:
  491. f.write(indented_str(2, "// API.setShowSecurityShieldDialog(true);"))
  492. f.write(os.linesep)
  493. if security["emulator"]:
  494. f.write(indented_str(2, "API.setCheckEmulator(true);"))
  495. f.write(os.linesep)
  496. else:
  497. f.write(indented_str(2, "// API.setCheckEmulator(true);"))
  498. f.write(os.linesep)
  499. if security["debug"]:
  500. f.write(indented_str(2, "API.setCheckAdb(true);"))
  501. f.write(os.linesep)
  502. else:
  503. f.write(indented_str(2, "// API.setCheckAdb(true);"))
  504. f.write(os.linesep)
  505. if security["sim_swap"]:
  506. f.write(indented_str(2, "API.setCheckSimSwap(true);"))
  507. f.write(os.linesep)
  508. else:
  509. f.write(indented_str(2, "// API.setCheckSimSwap(true);"))
  510. f.write(os.linesep)
  511. if security["malware"]:
  512. f.write(indented_str(2, "API.setCheckMalware(true);"))
  513. f.write(os.linesep)
  514. else:
  515. f.write(indented_str(2, "// API.setCheckMalware(true);"))
  516. f.write(os.linesep)
  517. if security["capture"]:
  518. f.write(indented_str(2, "API.setPreventScreenCapture(true);"))
  519. f.write(os.linesep)
  520. else:
  521. f.write(indented_str(2, "// API.setPreventScreenCapture(true);"))
  522. f.write(os.linesep)
  523. if security["call_forwarding"]:
  524. f.write(indented_str(2, "API.setCheckCallForwarding(true);"))
  525. f.write(os.linesep)
  526. else:
  527. f.write(indented_str(2, "// API.setCheckCallForwarding(true);"))
  528. f.write(os.linesep)
  529. if security["screen_share"]:
  530. f.write(indented_str(2, "API.setCheckScreenCasting(true);"))
  531. f.write(os.linesep)
  532. else:
  533. f.write(indented_str(2, "// API.setCheckScreenCasting(true);"))
  534. f.write(os.linesep)
  535. if security["side_load"]:
  536. f.write(indented_str(2, "API.setCheckSideLoadedApp(true);"))
  537. f.write(os.linesep)
  538. else:
  539. f.write(indented_str(2, "// API.setCheckSideLoadedApp(true);"))
  540. f.write(os.linesep)
  541. if security["key_logger"]:
  542. f.write(indented_str(2, "API.setPreventKeylogger(true);"))
  543. f.write(os.linesep)
  544. else:
  545. f.write(indented_str(2, "// API.setPreventKeylogger(true);"))
  546. f.write(os.linesep)
  547. elif "//SMS" in line:
  548. if features["sms"]["status"]:
  549. f.write(indented_str(2, "API.setEnabledSMS(true);"))
  550. else:
  551. f.write(indented_str(2, "// API.setEnabledSMS(true);"))
  552. elif "//EMAIL" in line:
  553. if features["email"]["status"]:
  554. f.write(indented_str(2, "API.setEnabledEmail(true);"))
  555. else:
  556. f.write(indented_str(2, "// API.setEnabledEmail(true);"))
  557. elif "//SMARTBOT" in line:
  558. if features["smartbot"]["status"]:
  559. f.write(indented_str(2, "API.setEnabledSmartBot(true);"))
  560. else:
  561. f.write(indented_str(2, "// API.setEnabledSmartBot(true);"))
  562. elif "//FLOATING" in line:
  563. if mode == "floating":
  564. f.write(indented_str(6, "ArrayList<FloatingButton> fb = new ArrayList<>();"))
  565. if features["cc"]["status"]:
  566. f.write(indented_str(6,
  567. 'fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
  568. else:
  569. f.write(indented_str(6,
  570. '// fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
  571. if features["nc"]["status"]:
  572. f.write(
  573. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
  574. else:
  575. f.write(indented_str(6,
  576. '// fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
  577. if features["im"]["status"]:
  578. f.write(
  579. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
  580. else:
  581. f.write(indented_str(6,
  582. '// fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
  583. if features["call"]["status"]:
  584. f.write(
  585. indented_str(6,
  586. 'fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
  587. else:
  588. f.write(indented_str(6,
  589. '// fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
  590. if features["ls"]["status"]:
  591. f.write(
  592. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
  593. else:
  594. f.write(indented_str(6,
  595. '// fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
  596. if security["secure_folder"]:
  597. f.write(
  598. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));'))
  599. else:
  600. f.write(indented_str(6,
  601. '// fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));'))
  602. f.write(indented_str(6,
  603. 'API.configureFloating(fb);'))
  604. else:
  605. f.write(indented_str(0, ""))
  606. elif "API.connect" in line:
  607. replaced = line
  608. if app_id:
  609. replaced = replaced.replace('***REPLACE***WITH***YOUR***APPLICATION***NAME***', app_id)
  610. if mode == "floating":
  611. replaced = replaced.replace("0", "1")
  612. f.write(replaced)
  613. else:
  614. f.write(line)
  615. write_android_manifest(manifest_path, features, security)
  616. elif platform == "android_ionic":
  617. main_act_path = os.path.join(path_dest,"src/app/app.component.ts")
  618. main_act_android = os.path.join(path_dest, "android/app/src/main/java/com/example/nexilissamplecodeionic/MainActivity.java")
  619. manifest_path = os.path.join(path_dest, "android/app/src/main/AndroidManifest.xml")
  620. with open(main_act_path, "r") as f:
  621. lines = f.readlines()
  622. with open(main_act_path, "w") as f:
  623. for line in lines:
  624. if "//FEATURES" in line:
  625. f.write(indented_str(4, '{', spaces=2))
  626. f.write(indented_str(5, "text: 'Settings',", spaces=2))
  627. f.write(indented_str(5, "handler: () => {", spaces=2))
  628. f.write(indented_str(6, "this.openSettings();", spaces=2))
  629. f.write(indented_str(5, "},", spaces=2))
  630. f.write(indented_str(4, "},", spaces=2))
  631. f.write(indented_str(4, '{', spaces=2))
  632. f.write(indented_str(5, "text: 'Profile',", spaces=2))
  633. f.write(indented_str(5, "handler: () => {", spaces=2))
  634. f.write(indented_str(6, "this.openProfile();", spaces=2))
  635. f.write(indented_str(5, "},", spaces=2))
  636. f.write(indented_str(4, "},", spaces=2))
  637. if features["cc"]["status"]:
  638. f.write(indented_str(4, '{', spaces=2))
  639. f.write(indented_str(5, "text: 'Contact Center',", spaces=2))
  640. f.write(indented_str(5, "handler: () => {", spaces=2))
  641. f.write(indented_str(6, "this.openContactCenter();", spaces=2))
  642. f.write(indented_str(5, "},", spaces=2))
  643. f.write(indented_str(4, "},", spaces=2))
  644. else:
  645. f.write(indented_str(4, '// {', spaces=2))
  646. f.write(indented_str(5, "// text: 'Contact Center',", spaces=2))
  647. f.write(indented_str(5, "// handler: () => {", spaces=2))
  648. f.write(indented_str(6, "// this.openContactCenter();", spaces=2))
  649. f.write(indented_str(5, "// },", spaces=2))
  650. f.write(indented_str(4, "// },", spaces=2))
  651. if features["nc"]["status"]:
  652. f.write(indented_str(4, '{', spaces=2))
  653. f.write(indented_str(5, "text: 'Notification Center',", spaces=2))
  654. f.write(indented_str(5, "handler: () => {", spaces=2))
  655. f.write(indented_str(6, "this.openNotificationCenter();", spaces=2))
  656. f.write(indented_str(5, "},", spaces=2))
  657. f.write(indented_str(4, "},", spaces=2))
  658. else:
  659. f.write(indented_str(4, '// {', spaces=2))
  660. f.write(indented_str(5, "// text: 'Notification Center',", spaces=2))
  661. f.write(indented_str(5, "// handler: () => {", spaces=2))
  662. f.write(indented_str(6, "// this.openNotificationCenter();", spaces=2))
  663. f.write(indented_str(5, "// },", spaces=2))
  664. f.write(indented_str(4, "// },", spaces=2))
  665. if features["im"]["status"]:
  666. f.write(indented_str(4, '{', spaces=2))
  667. f.write(indented_str(5, "text: 'Instant Messaging',", spaces=2))
  668. f.write(indented_str(5, "handler: () => {", spaces=2))
  669. f.write(indented_str(6, "this.openChat();", spaces=2))
  670. f.write(indented_str(5, "},", spaces=2))
  671. f.write(indented_str(4, "},", spaces=2))
  672. else:
  673. f.write(indented_str(4, '// {', spaces=2))
  674. f.write(indented_str(5, "// text: 'Instant Messaging',", spaces=2))
  675. f.write(indented_str(5, "// handler: () => {", spaces=2))
  676. f.write(indented_str(6, "// this.openChat();", spaces=2))
  677. f.write(indented_str(5, "// },", spaces=2))
  678. f.write(indented_str(4, "// },", spaces=2))
  679. if features["call"]["status"]:
  680. f.write(indented_str(4, '{', spaces=2))
  681. f.write(indented_str(5, "text: 'Call',", spaces=2))
  682. f.write(indented_str(5, "handler: () => {", spaces=2))
  683. f.write(indented_str(6, "this.openCall();", spaces=2))
  684. f.write(indented_str(5, "},", spaces=2))
  685. f.write(indented_str(4, "},", spaces=2))
  686. else:
  687. f.write(indented_str(4, '// {', spaces=2))
  688. f.write(indented_str(5, "// text: 'Call',", spaces=2))
  689. f.write(indented_str(5, "// handler: () => {", spaces=2))
  690. f.write(indented_str(6, "// this.openCall();", spaces=2))
  691. f.write(indented_str(5, "// },", spaces=2))
  692. f.write(indented_str(4, "// },", spaces=2))
  693. if features["ls"]["status"]:
  694. f.write(indented_str(4, '{', spaces=2))
  695. f.write(indented_str(5, "text: 'Streaming',", spaces=2))
  696. f.write(indented_str(5, "handler: () => {", spaces=2))
  697. f.write(indented_str(6, "this.openStreaming();", spaces=2))
  698. f.write(indented_str(5, "},", spaces=2))
  699. f.write(indented_str(4, "},", spaces=2))
  700. else:
  701. f.write(indented_str(4, '// {', spaces=2))
  702. f.write(indented_str(5, "// text: 'Streaming',", spaces=2))
  703. f.write(indented_str(5, "// handler: () => {", spaces=2))
  704. f.write(indented_str(6, "// this.openStreaming();", spaces=2))
  705. f.write(indented_str(5, "// },", spaces=2))
  706. f.write(indented_str(4, "// },", spaces=2))
  707. if security["secure_folder"]:
  708. f.write(indented_str(4, '{', spaces=2))
  709. f.write(indented_str(5, "text: 'Secure Folder',", spaces=2))
  710. f.write(indented_str(5, "handler: () => {", spaces=2))
  711. f.write(indented_str(6, "this.openSecureFolder();", spaces=2))
  712. f.write(indented_str(5, "},", spaces=2))
  713. f.write(indented_str(4, "},", spaces=2))
  714. else:
  715. f.write(indented_str(4, '// {', spaces=2))
  716. f.write(indented_str(5, "// text: 'Secure Folder',", spaces=2))
  717. f.write(indented_str(5, "// handler: () => {", spaces=2))
  718. f.write(indented_str(6, "// this.openSecureFolder();", spaces=2))
  719. f.write(indented_str(5, "// },", spaces=2))
  720. f.write(indented_str(4, "// },", spaces=2))
  721. else:
  722. f.write(line)
  723. with open(main_act_android, "r") as f:
  724. lines = f.readlines()
  725. with open(main_act_android, "w") as f:
  726. for line in lines:
  727. if "//SECURITY" in line:
  728. if security["show_security"]:
  729. f.write(indented_str(2, "API.setShowSecurityShieldDialog(true);", spaces=2))
  730. f.write(os.linesep)
  731. else:
  732. f.write(indented_str(2, "// API.setShowSecurityShieldDialog(true);", spaces=2))
  733. f.write(os.linesep)
  734. if security["emulator"]:
  735. f.write(indented_str(2, "API.setCheckEmulator(true);", spaces=2))
  736. f.write(os.linesep)
  737. else:
  738. f.write(indented_str(2, "// API.setCheckEmulator(true);", spaces=2))
  739. f.write(os.linesep)
  740. if security["debug"]:
  741. f.write(indented_str(2, "API.setCheckAdb(true);", spaces=2))
  742. f.write(os.linesep)
  743. else:
  744. f.write(indented_str(2, "// API.setCheckAdb(true);", spaces=2))
  745. f.write(os.linesep)
  746. if security["sim_swap"]:
  747. f.write(indented_str(2, "API.setCheckSimSwap(true);", spaces=2))
  748. f.write(os.linesep)
  749. else:
  750. f.write(indented_str(2, "// API.setCheckSimSwap(true);", spaces=2))
  751. f.write(os.linesep)
  752. if security["malware"]:
  753. f.write(indented_str(2, "API.setCheckMalware(true);", spaces=2))
  754. f.write(os.linesep)
  755. else:
  756. f.write(indented_str(2, "// API.setCheckMalware(true);", spaces=2))
  757. f.write(os.linesep)
  758. if security["capture"]:
  759. f.write(indented_str(2, "API.setPreventScreenCapture(true);", spaces=2))
  760. f.write(os.linesep)
  761. else:
  762. f.write(indented_str(2, "// API.setPreventScreenCapture(true);", spaces=2))
  763. f.write(os.linesep)
  764. if security["call_forwarding"]:
  765. f.write(indented_str(2, "API.setCheckCallForwarding(true);", spaces=2))
  766. f.write(os.linesep)
  767. else:
  768. f.write(indented_str(2, "// API.setCheckCallForwarding(true);", spaces=2))
  769. f.write(os.linesep)
  770. if security["screen_share"]:
  771. f.write(indented_str(2, "API.setCheckScreenCasting(true);", spaces=2))
  772. f.write(os.linesep)
  773. else:
  774. f.write(indented_str(2, "// API.setCheckScreenCasting(true);", spaces=2))
  775. f.write(os.linesep)
  776. if security["side_load"]:
  777. f.write(indented_str(2, "API.setCheckSideLoadedApp(true);", spaces=2))
  778. f.write(os.linesep)
  779. else:
  780. f.write(indented_str(2, "// API.setCheckSideLoadedApp(true);", spaces=2))
  781. f.write(os.linesep)
  782. if security["key_logger"]:
  783. f.write(indented_str(2, "API.setPreventKeylogger(true);", spaces=2))
  784. f.write(os.linesep)
  785. else:
  786. f.write(indented_str(2, "// API.setPreventKeylogger(true);", spaces=2))
  787. f.write(os.linesep)
  788. elif "//SMS" in line:
  789. if features["sms"]["status"]:
  790. f.write(indented_str(2, "API.setEnabledSMS(true);", spaces=2))
  791. else:
  792. f.write(indented_str(2, "// API.setEnabledSMS(true);", spaces=2))
  793. elif "//EMAIL" in line:
  794. if features["email"]["status"]:
  795. f.write(indented_str(2, "API.setEnabledEmail(true);", spaces=2))
  796. else:
  797. f.write(indented_str(2, "// API.setEnabledEmail(true);", spaces=2))
  798. elif "//SMARTBOT" in line:
  799. if features["smartbot"]["status"]:
  800. f.write(indented_str(2, "API.setEnabledSmartBot(true);"))
  801. else:
  802. f.write(indented_str(2, "// API.setEnabledSmartBot(true);"))
  803. elif "//FLOATING" in line:
  804. if mode == "floating":
  805. f.write(indented_str(6, "ArrayList<FloatingButton> fb = new ArrayList<>();", spaces=2))
  806. if features["cc"]["status"]:
  807. f.write(indented_str(6,
  808. 'fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));', spaces=2))
  809. else:
  810. f.write(indented_str(6,
  811. '// fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));', spaces=2))
  812. if features["nc"]["status"]:
  813. f.write(
  814. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));', spaces=2))
  815. else:
  816. f.write(indented_str(6,
  817. '// fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));', spaces=2))
  818. if features["im"]["status"]:
  819. f.write(
  820. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));', spaces=2))
  821. else:
  822. f.write(indented_str(6,
  823. '// fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));', spaces=2))
  824. if features["call"]["status"]:
  825. f.write(
  826. indented_str(6,
  827. 'fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));', spaces=2))
  828. else:
  829. f.write(indented_str(6,
  830. '// fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));', spaces=2))
  831. if features["ls"]["status"]:
  832. f.write(
  833. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));', spaces=2))
  834. else:
  835. f.write(indented_str(6,
  836. '// fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));', spaces=2))
  837. if security["secure_folder"]:
  838. f.write(
  839. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));', spaces=2))
  840. else:
  841. f.write(indented_str(6,
  842. '// fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));', spaces=2))
  843. f.write(indented_str(6,
  844. 'API.configureFloating(fb);', spaces=2))
  845. else:
  846. f.write(indented_str(0, "", spaces=2))
  847. elif "API.connect" in line:
  848. replaced = line
  849. if app_id:
  850. replaced = replaced.replace('***REPLACE***WITH***YOUR***APPLICATION***NAME***', app_id)
  851. if mode == "floating":
  852. replaced = replaced.replace("0", "1")
  853. f.write(replaced)
  854. else:
  855. f.write(line)
  856. write_android_manifest(manifest_path, features, security)
  857. elif platform == "android_react":
  858. main_act_path = os.path.join(path_dest, "App.tsx")
  859. main_act_android = os.path.join(path_dest, "android/app/src/main/java/com/paliolitesamplecode/MainActivity.java")
  860. manifest_path = os.path.join(path_dest, "android/app/src/main/AndroidManifest.xml")
  861. with open(main_act_path, "r") as f:
  862. lines = f.readlines()
  863. with open(main_act_path, "w") as f:
  864. for line in lines:
  865. if "'Features'" in line:
  866. f.write(indented_str(4, "'Setting',", spaces=2))
  867. f.write(indented_str(4, "'Profile',", spaces=2))
  868. if features["cc"]["status"]:
  869. f.write(indented_str(4, "'Contact Center',", spaces=2))
  870. else:
  871. f.write(indented_str(4, "// 'Contact Center',", spaces=2))
  872. if features["nc"]["status"]:
  873. f.write(indented_str(4, "'Notification Center',", spaces=2))
  874. else:
  875. f.write(indented_str(4, "// 'Notification Center',", spaces=2))
  876. if features["im"]["status"]:
  877. f.write(indented_str(4, "'Chat',", spaces=2))
  878. else:
  879. f.write(indented_str(4, "// 'Chat',", spaces=2))
  880. if features["call"]["status"]:
  881. f.write(indented_str(4, "'Call',", spaces=2))
  882. else:
  883. f.write(indented_str(4, "// 'Call',", spaces=2))
  884. if features["ls"]["status"]:
  885. f.write(indented_str(4, "'Live Streaming',", spaces=2))
  886. else:
  887. f.write(indented_str(4, "// 'Live Streaming',", spaces=2))
  888. if security["secure_folder"]:
  889. f.write(indented_str(4, "'Secure Folder',", spaces=2))
  890. else:
  891. f.write(indented_str(4, "// 'Secure Folder',", spaces=2))
  892. elif "//FEATURES1" in line:
  893. n = 0
  894. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  895. f.write(indented_str(6, "CallNative.openSetting();", spaces=2))
  896. f.write(indented_str(5, "}", spaces=2))
  897. n = n + 1
  898. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  899. f.write(indented_str(6, "CallNative.openProfile();", spaces=2))
  900. f.write(indented_str(5, "}", spaces=2))
  901. n = n + 1
  902. if features["cc"]["status"]:
  903. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  904. f.write(indented_str(6, "CallNative.openContactCenter();", spaces=2))
  905. f.write(indented_str(5, "}", spaces=2))
  906. n = n + 1
  907. else:
  908. f.write(indented_str(5, "// if (buttonIndex === 2) {", spaces=2))
  909. f.write(indented_str(6, "// CallNative.openContactCenter();", spaces=2))
  910. f.write(indented_str(5, "// }", spaces=2))
  911. if features["nc"]["status"]:
  912. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  913. f.write(indented_str(6, "CallNative.openNotificationCenter();", spaces=2))
  914. f.write(indented_str(5, "}", spaces=2))
  915. n = n + 1
  916. else:
  917. f.write(indented_str(5, "// if (buttonIndex === 3) {", spaces=2))
  918. f.write(indented_str(6, "// CallNative.openNotificationCenter();", spaces=2))
  919. f.write(indented_str(5, "// }", spaces=2))
  920. if features["im"]["status"]:
  921. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  922. f.write(indented_str(6, "CallNative.openChat();", spaces=2))
  923. f.write(indented_str(5, "}", spaces=2))
  924. n = n + 1
  925. else:
  926. f.write(indented_str(5, "// if (buttonIndex === 4) {", spaces=2))
  927. f.write(indented_str(6, "// CallNative.openChat();", spaces=2))
  928. f.write(indented_str(5, "// }", spaces=2))
  929. if features["call"]["status"]:
  930. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  931. f.write(indented_str(6, "CallNative.openCall();", spaces=2))
  932. f.write(indented_str(5, "}", spaces=2))
  933. n = n + 1
  934. else:
  935. f.write(indented_str(5, "// if (buttonIndex === 5) {", spaces=2))
  936. f.write(indented_str(6, "// CallNative.openCall();", spaces=2))
  937. f.write(indented_str(5, "// }", spaces=2))
  938. if features["ls"]["status"]:
  939. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  940. f.write(indented_str(6, "CallNative.openStreaming();", spaces=2))
  941. f.write(indented_str(5, "}", spaces=2))
  942. n = n + 1
  943. else:
  944. f.write(indented_str(5, "// if (buttonIndex === 6) {", spaces=2))
  945. f.write(indented_str(6, "// CallNative.openStreaming();", spaces=2))
  946. f.write(indented_str(5, "// }", spaces=2))
  947. if security["secure_folder"]:
  948. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  949. f.write(indented_str(6, "CallNative.openSecureFolder();", spaces=2))
  950. f.write(indented_str(5, "}", spaces=2))
  951. n = n + 1
  952. else:
  953. f.write(indented_str(5, "// if (buttonIndex === 7) {", spaces=2))
  954. f.write(indented_str(6, "// CallNative.openSecureFolder();", spaces=2))
  955. f.write(indented_str(5, "// }", spaces=2))
  956. elif "//FEATURES2" in line:
  957. n = 0
  958. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  959. f.write(indented_str(3, "try {", spaces=2))
  960. f.write(indented_str(4, "CallNative.openSetting();", spaces=2))
  961. f.write(indented_str(3, "} catch (e) {", spaces=2))
  962. f.write(indented_str(4, "console.log(e);", spaces=2))
  963. f.write(indented_str(3, "}", spaces=2))
  964. f.write(indented_str(2, "}", spaces=2))
  965. n = n + 1
  966. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  967. f.write(indented_str(3, "try {", spaces=2))
  968. f.write(indented_str(4, "CallNative.openProfile();", spaces=2))
  969. f.write(indented_str(3, "} catch (e) {", spaces=2))
  970. f.write(indented_str(4, "console.log(e);", spaces=2))
  971. f.write(indented_str(3, "}", spaces=2))
  972. f.write(indented_str(2, "}", spaces=2))
  973. n = n + 1
  974. if features["cc"]["status"]:
  975. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  976. f.write(indented_str(3, "try {", spaces=2))
  977. f.write(indented_str(4, "CallNative.openContactCenter();", spaces=2))
  978. f.write(indented_str(3, "} catch (e) {", spaces=2))
  979. f.write(indented_str(4, "console.log(e);", spaces=2))
  980. f.write(indented_str(3, "}", spaces=2))
  981. f.write(indented_str(2, "}", spaces=2))
  982. n = n + 1
  983. else:
  984. f.write(indented_str(2, "// if (buttonIndex === 2) {", spaces=2))
  985. f.write(indented_str(3, "// try {", spaces=2))
  986. f.write(indented_str(4, "// CallNative.openContactCenter();", spaces=2))
  987. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  988. f.write(indented_str(4, "// console.log(e);", spaces=2))
  989. f.write(indented_str(3, "// }", spaces=2))
  990. f.write(indented_str(2, "// }", spaces=2))
  991. if features["nc"]["status"]:
  992. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  993. f.write(indented_str(3, "try {", spaces=2))
  994. f.write(indented_str(4, "CallNative.openNotificationCenter();", spaces=2))
  995. f.write(indented_str(3, "} catch (e) {", spaces=2))
  996. f.write(indented_str(4, "console.log(e);", spaces=2))
  997. f.write(indented_str(3, "}", spaces=2))
  998. f.write(indented_str(2, "}", spaces=2))
  999. n = n + 1
  1000. else:
  1001. f.write(indented_str(2, "// if (buttonIndex === 3) {", spaces=2))
  1002. f.write(indented_str(3, "// try {", spaces=2))
  1003. f.write(indented_str(4, "// CallNative.openNotificationCenter();", spaces=2))
  1004. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1005. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1006. f.write(indented_str(3, "// }", spaces=2))
  1007. f.write(indented_str(2, "// }", spaces=2))
  1008. if features["im"]["status"]:
  1009. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1010. f.write(indented_str(3, "try {", spaces=2))
  1011. f.write(indented_str(4, "CallNative.openChat();", spaces=2))
  1012. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1013. f.write(indented_str(4, "console.log(e);", spaces=2))
  1014. f.write(indented_str(3, "}", spaces=2))
  1015. f.write(indented_str(2, "}", spaces=2))
  1016. n = n + 1
  1017. else:
  1018. f.write(indented_str(2, "// if (buttonIndex === 4) {", spaces=2))
  1019. f.write(indented_str(3, "// try {", spaces=2))
  1020. f.write(indented_str(4, "// CallNative.openChat();", spaces=2))
  1021. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1022. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1023. f.write(indented_str(3, "// }", spaces=2))
  1024. f.write(indented_str(2, "// }", spaces=2))
  1025. if features["call"]["status"]:
  1026. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1027. f.write(indented_str(3, "try {", spaces=2))
  1028. f.write(indented_str(4, "CallNative.openCall();", spaces=2))
  1029. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1030. f.write(indented_str(4, "console.log(e);", spaces=2))
  1031. f.write(indented_str(3, "}", spaces=2))
  1032. f.write(indented_str(2, "}", spaces=2))
  1033. n = n + 1
  1034. else:
  1035. f.write(indented_str(2, "// if (buttonIndex === 5) {", spaces=2))
  1036. f.write(indented_str(3, "// try {", spaces=2))
  1037. f.write(indented_str(4, "// CallNative.openCall();", spaces=2))
  1038. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1039. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1040. f.write(indented_str(3, "// }", spaces=2))
  1041. f.write(indented_str(2, "// }", spaces=2))
  1042. if features["ls"]["status"]:
  1043. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1044. f.write(indented_str(3, "try {", spaces=2))
  1045. f.write(indented_str(4, "CallNative.openStreaming();", spaces=2))
  1046. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1047. f.write(indented_str(4, "console.log(e);", spaces=2))
  1048. f.write(indented_str(3, "}", spaces=2))
  1049. f.write(indented_str(2, "}", spaces=2))
  1050. n = n + 1
  1051. else:
  1052. f.write(indented_str(2, "// if (buttonIndex === 6) {", spaces=2))
  1053. f.write(indented_str(3, "// try {", spaces=2))
  1054. f.write(indented_str(4, "// CallNative.openStreaming();", spaces=2))
  1055. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1056. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1057. f.write(indented_str(3, "// }", spaces=2))
  1058. f.write(indented_str(2, "// }", spaces=2))
  1059. if security["secure_folder"]:
  1060. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1061. f.write(indented_str(3, "try {", spaces=2))
  1062. f.write(indented_str(4, "CallNative.openSecureFolder();", spaces=2))
  1063. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1064. f.write(indented_str(4, "console.log(e);", spaces=2))
  1065. f.write(indented_str(3, "}", spaces=2))
  1066. f.write(indented_str(2, "}", spaces=2))
  1067. n = n + 1
  1068. else:
  1069. f.write(indented_str(2, "// if (buttonIndex === 7) {", spaces=2))
  1070. f.write(indented_str(3, "// try {", spaces=2))
  1071. f.write(indented_str(4, "// CallNative.openSecureFolder();", spaces=2))
  1072. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1073. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1074. f.write(indented_str(3, "// }", spaces=2))
  1075. f.write(indented_str(2, "// }", spaces=2))
  1076. elif "//FEATURES3" in line:
  1077. n = 0
  1078. f.write(indented_str(5, "<Button", spaces=2))
  1079. f.write(indented_str(6, 'title="Setting"', spaces=2))
  1080. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1081. f.write(indented_str(5, "/>", spaces=2))
  1082. n = n + 1
  1083. f.write(indented_str(5, "<Button", spaces=2))
  1084. f.write(indented_str(6, 'title="Profile"', spaces=2))
  1085. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1086. f.write(indented_str(5, "/>", spaces=2))
  1087. n = n + 1
  1088. if features["cc"]["status"]:
  1089. f.write(indented_str(5, "<Button", spaces=2))
  1090. f.write(indented_str(6, 'title="Contact Center"', spaces=2))
  1091. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1092. f.write(indented_str(5, "/>", spaces=2))
  1093. n = n + 1
  1094. else:
  1095. f.write(indented_str(5, "{/* <Button", spaces=2))
  1096. f.write(indented_str(6, 'title="Contact Center"', spaces=2))
  1097. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(2)}}', spaces=2))
  1098. f.write(indented_str(5, "/> */}", spaces=2))
  1099. if features["nc"]["status"]:
  1100. f.write(indented_str(5, "<Button", spaces=2))
  1101. f.write(indented_str(6, 'title="Notification Center"', spaces=2))
  1102. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1103. f.write(indented_str(5, "/>", spaces=2))
  1104. n = n + 1
  1105. else:
  1106. f.write(indented_str(5, "{/* <Button", spaces=2))
  1107. f.write(indented_str(6, 'title="Notification Center"', spaces=2))
  1108. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(3)}}', spaces=2))
  1109. f.write(indented_str(5, "/> */}", spaces=2))
  1110. if features["im"]["status"]:
  1111. f.write(indented_str(5, "<Button", spaces=2))
  1112. f.write(indented_str(6, 'title="Chat"', spaces=2))
  1113. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1114. f.write(indented_str(5, "/>", spaces=2))
  1115. n = n + 1
  1116. else:
  1117. f.write(indented_str(5, "{/* <Button", spaces=2))
  1118. f.write(indented_str(6, 'title="Chat"', spaces=2))
  1119. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(4)}}', spaces=2))
  1120. f.write(indented_str(5, "/> */}", spaces=2))
  1121. if features["call"]["status"]:
  1122. f.write(indented_str(5, "<Button", spaces=2))
  1123. f.write(indented_str(6, 'title="Call"', spaces=2))
  1124. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1125. f.write(indented_str(5, "/>", spaces=2))
  1126. n = n + 1
  1127. else:
  1128. f.write(indented_str(5, "{/* <Button", spaces=2))
  1129. f.write(indented_str(6, 'title="Call"', spaces=2))
  1130. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(5)}}', spaces=2))
  1131. f.write(indented_str(5, "/> */}", spaces=2))
  1132. if features["ls"]["status"]:
  1133. f.write(indented_str(5, "<Button", spaces=2))
  1134. f.write(indented_str(6, 'title="Live Streaming"', spaces=2))
  1135. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1136. f.write(indented_str(5, "/>", spaces=2))
  1137. n = n + 1
  1138. else:
  1139. f.write(indented_str(5, "{/* <Button", spaces=2))
  1140. f.write(indented_str(6, 'title="Live Streaming"', spaces=2))
  1141. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(6)}}', spaces=2))
  1142. f.write(indented_str(5, "/> */}", spaces=2))
  1143. if security["secure_folder"]:
  1144. f.write(indented_str(5, "<Button", spaces=2))
  1145. f.write(indented_str(6, 'title="Secure Folder"', spaces=2))
  1146. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1147. f.write(indented_str(5, "/>", spaces=2))
  1148. n = n + 1
  1149. else:
  1150. f.write(indented_str(5, "{/* <Button", spaces=2))
  1151. f.write(indented_str(6, 'title="Secure Folder"', spaces=2))
  1152. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(7)}}', spaces=2))
  1153. f.write(indented_str(5, "/> */}", spaces=2))
  1154. else:
  1155. f.write(line)
  1156. with open(main_act_android, "r") as f:
  1157. lines = f.readlines()
  1158. with open(main_act_android, "w") as f:
  1159. for line in lines:
  1160. if "//SECURITY" in line:
  1161. if security["show_security"]:
  1162. f.write(indented_str(2, "API.setShowSecurityShieldDialog(true);"))
  1163. f.write(os.linesep)
  1164. else:
  1165. f.write(indented_str(2, "// API.setShowSecurityShieldDialog(true);"))
  1166. f.write(os.linesep)
  1167. if security["emulator"]:
  1168. f.write(indented_str(2, "API.setCheckEmulator(true);"))
  1169. f.write(os.linesep)
  1170. else:
  1171. f.write(indented_str(2, "// API.setCheckEmulator(true);"))
  1172. f.write(os.linesep)
  1173. if security["debug"]:
  1174. f.write(indented_str(2, "API.setCheckAdb(true);"))
  1175. f.write(os.linesep)
  1176. else:
  1177. f.write(indented_str(2, "// API.setCheckAdb(true);"))
  1178. f.write(os.linesep)
  1179. if security["sim_swap"]:
  1180. f.write(indented_str(2, "API.setCheckSimSwap(true);"))
  1181. f.write(os.linesep)
  1182. else:
  1183. f.write(indented_str(2, "// API.setCheckSimSwap(true);"))
  1184. f.write(os.linesep)
  1185. if security["malware"]:
  1186. f.write(indented_str(2, "API.setCheckMalware(true);"))
  1187. f.write(os.linesep)
  1188. else:
  1189. f.write(indented_str(2, "// API.setCheckMalware(true);"))
  1190. f.write(os.linesep)
  1191. if security["capture"]:
  1192. f.write(indented_str(2, "API.setPreventScreenCapture(true);"))
  1193. f.write(os.linesep)
  1194. else:
  1195. f.write(indented_str(2, "// API.setPreventScreenCapture(true);"))
  1196. f.write(os.linesep)
  1197. if security["call_forwarding"]:
  1198. f.write(indented_str(2, "API.setCheckCallForwarding(true);"))
  1199. f.write(os.linesep)
  1200. else:
  1201. f.write(indented_str(2, "// API.setCheckCallForwarding(true);"))
  1202. f.write(os.linesep)
  1203. if security["screen_share"]:
  1204. f.write(indented_str(2, "API.setCheckScreenCasting(true);"))
  1205. f.write(os.linesep)
  1206. else:
  1207. f.write(indented_str(2, "// API.setCheckScreenCasting(true);"))
  1208. f.write(os.linesep)
  1209. if security["side_load"]:
  1210. f.write(indented_str(2, "API.setCheckSideLoadedApp(true);"))
  1211. f.write(os.linesep)
  1212. else:
  1213. f.write(indented_str(2, "// API.setCheckSideLoadedApp(true);"))
  1214. f.write(os.linesep)
  1215. if security["key_logger"]:
  1216. f.write(indented_str(2, "API.setPreventKeylogger(true);"))
  1217. f.write(os.linesep)
  1218. else:
  1219. f.write(indented_str(2, "// API.setPreventKeylogger(true);"))
  1220. f.write(os.linesep)
  1221. elif "//SMS" in line:
  1222. if features["sms"]["status"]:
  1223. f.write(indented_str(2, "API.setEnabledSMS(true);"))
  1224. else:
  1225. f.write(indented_str(2, "// API.setEnabledSMS(true);"))
  1226. elif "//EMAIL" in line:
  1227. if features["email"]["status"]:
  1228. f.write(indented_str(2, "API.setEnabledEmail(true);"))
  1229. else:
  1230. f.write(indented_str(2, "// API.setEnabledEmail(true);"))
  1231. elif "//SMARTBOT" in line:
  1232. if features["smartbot"]["status"]:
  1233. f.write(indented_str(2, "API.setEnabledSmartBot(true);"))
  1234. else:
  1235. f.write(indented_str(2, "// API.setEnabledSmartBot(true);"))
  1236. elif "//FLOATING" in line:
  1237. if mode == "floating":
  1238. f.write(indented_str(6, "ArrayList<FloatingButton> fb = new ArrayList<>();"))
  1239. if features["cc"]["status"]:
  1240. f.write(indented_str(6,
  1241. 'fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
  1242. else:
  1243. f.write(indented_str(6,
  1244. '// fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
  1245. if features["nc"]["status"]:
  1246. f.write(
  1247. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
  1248. else:
  1249. f.write(indented_str(6,
  1250. '// fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
  1251. if features["im"]["status"]:
  1252. f.write(
  1253. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
  1254. else:
  1255. f.write(indented_str(6,
  1256. '// fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
  1257. if features["call"]["status"]:
  1258. f.write(
  1259. indented_str(6,
  1260. 'fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
  1261. else:
  1262. f.write(indented_str(6,
  1263. '// fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
  1264. if features["ls"]["status"]:
  1265. f.write(
  1266. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
  1267. else:
  1268. f.write(indented_str(6,
  1269. '// fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
  1270. if security["secure_folder"]:
  1271. f.write(
  1272. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));'))
  1273. else:
  1274. f.write(indented_str(6,
  1275. '// fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));'))
  1276. f.write(indented_str(6,
  1277. 'API.configureFloating(fb);'))
  1278. else:
  1279. f.write(indented_str(0, ""))
  1280. elif "API.connect" in line:
  1281. replaced = line
  1282. if app_id:
  1283. replaced = replaced.replace('***REPLACE***WITH***YOUR***APPLICATION***NAME***', app_id)
  1284. if mode == "floating":
  1285. replaced = replaced.replace("0", "1")
  1286. f.write(replaced)
  1287. else:
  1288. f.write(line)
  1289. write_android_manifest(manifest_path, features, security)
  1290. elif platform == "ios":
  1291. main_act_path = os.path.join(path_dest, "ExampleCode/ViewController.swift")
  1292. with open(main_act_path, "r") as f:
  1293. lines = f.readlines()
  1294. with open(main_act_path, "w") as f:
  1295. for line in lines:
  1296. if "//FEATURES" in line:
  1297. f.write(indented_str(3, 'UIAction(title: "Setting".localized(), handler: {(_) in'))
  1298. f.write(indented_str(4, "APIS.openSetting();"))
  1299. f.write(indented_str(3, "}),"))
  1300. f.write(indented_str(3, 'UIAction(title: "Profile".localized(), handler: {(_) in'))
  1301. f.write(indented_str(4, "APIS.openProfile();"))
  1302. f.write(indented_str(3, "}),"))
  1303. if features["cc"]["status"]:
  1304. f.write(indented_str(3, 'UIAction(title: "Contact Center".localized(), handler: {(_) in'))
  1305. f.write(indented_str(4, "APIS.openContactCenter();"))
  1306. f.write(indented_str(3, "}),"))
  1307. else:
  1308. f.write(indented_str(3, '// UIAction(title: "Contact Center".localized(), handler: {(_) in'))
  1309. f.write(indented_str(4, "// APIS.openContactCenter();"))
  1310. f.write(indented_str(3, "// }),"))
  1311. if features["nc"]["status"]:
  1312. f.write(indented_str(3, 'UIAction(title: "Notification Center".localized(), handler: {(_) in'))
  1313. f.write(indented_str(4, "APIS.openNotificationCenter();"))
  1314. f.write(indented_str(3, "}),"))
  1315. else:
  1316. f.write(indented_str(3, '// UIAction(title: "Notification Center".localized(), handler: {(_) in'))
  1317. f.write(indented_str(4, "// APIS.openNotificationCenter();"))
  1318. f.write(indented_str(3, "// }),"))
  1319. if features["im"]["status"]:
  1320. f.write(indented_str(3, 'UIAction(title: "Chat".localized(), handler: {(_) in'))
  1321. f.write(indented_str(4, "APIS.openChat();"))
  1322. f.write(indented_str(3, "}),"))
  1323. else:
  1324. f.write(indented_str(3, '// UIAction(title: "Chat".localized(), handler: {(_) in'))
  1325. f.write(indented_str(4, "// APIS.openChat();"))
  1326. f.write(indented_str(3, "// }),"))
  1327. if features["call"]["status"]:
  1328. f.write(indented_str(3, 'UIAction(title: "Call".localized(), handler: {(_) in'))
  1329. f.write(indented_str(4, "APIS.openCall();"))
  1330. f.write(indented_str(3, "}),"))
  1331. else:
  1332. f.write(indented_str(3, '// UIAction(title: "Call".localized(), handler: {(_) in'))
  1333. f.write(indented_str(4, "// APIS.openCall();"))
  1334. f.write(indented_str(3, "// }),"))
  1335. if features["ls"]["status"]:
  1336. f.write(indented_str(3, 'UIAction(title: "Live Streaming".localized(), handler: {(_) in'))
  1337. f.write(indented_str(4, "APIS.openStreaming();"))
  1338. f.write(indented_str(3, "}),"))
  1339. else:
  1340. f.write(indented_str(3, '// UIAction(title: "Live Streaming".localized(), handler: {(_) in'))
  1341. f.write(indented_str(4, "// APIS.openStreaming();"))
  1342. f.write(indented_str(3, "// }),"))
  1343. elif "//FLOATING" in line:
  1344. if mode == "floating":
  1345. if features["cc"]["status"]:
  1346. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1347. else:
  1348. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1349. if features["nc"]["status"]:
  1350. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1351. else:
  1352. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1353. if features["im"]["status"]:
  1354. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1355. else:
  1356. f.write(indented_str(2,'// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1357. if features["call"]["status"]:
  1358. f.write(indented_str(2,'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1359. else:
  1360. f.write(indented_str(2,'// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1361. if features["ls"]["status"]:
  1362. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1363. else:
  1364. f.write(indented_str(2,'// Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1365. else:
  1366. f.write(indented_str(0, ""))
  1367. elif "APIS.connect" in line:
  1368. if mode == "floating":
  1369. replaced = line.replace("false", "true")
  1370. f.write(replaced)
  1371. else:
  1372. f.write(line)
  1373. else:
  1374. f.write(line)
  1375. elif platform == "ios_flutter":
  1376. main_act_path = os.path.join(path_dest, "lib/main.dart")
  1377. main_act_ios = os.path.join(path_dest, "ios/Runner/AppDelegate.swift")
  1378. with open(main_act_path, "r") as f:
  1379. lines = f.readlines()
  1380. with open(main_act_path, "w") as f:
  1381. features_str = []
  1382. for line in lines:
  1383. if "'Features List'" in line:
  1384. features_str.append("'Settings'")
  1385. features_str.append("'Profile'")
  1386. if features["cc"]["status"]:
  1387. features_str.append("'Contact Center'")
  1388. else:
  1389. features_str.append("// 'Contact Center'")
  1390. if features["nc"]["status"]:
  1391. features_str.append("'Notification Center'")
  1392. else:
  1393. features_str.append("// 'Notification Center'")
  1394. if features["im"]["status"]:
  1395. features_str.append("'Instant Messaging'")
  1396. else:
  1397. features_str.append("// 'Instant Messaging'")
  1398. if features["call"]["status"]:
  1399. features_str.append("'Call'")
  1400. else:
  1401. features_str.append("// 'Call'")
  1402. if features["ls"]["status"]:
  1403. features_str.append("'Streaming'")
  1404. else:
  1405. features_str.append("// 'Streaming'")
  1406. for feature_str in features_str:
  1407. f.write(indented_str(8, f"{feature_str},", spaces=2))
  1408. elif "//FEATURES" in line:
  1409. f.write(indented_str(3, 'case "Settings":', spaces=2))
  1410. f.write(indented_str(4, 'nativeChannel.invokeMethod("openSettings");', spaces=2))
  1411. f.write(indented_str(4, "break;", spaces=2))
  1412. f.write(indented_str(3, 'case "Profile":', spaces=2))
  1413. f.write(indented_str(4, 'nativeChannel.invokeMethod("openProfile");', spaces=2))
  1414. f.write(indented_str(4, "break;", spaces=2))
  1415. if features["cc"]["status"]:
  1416. f.write(indented_str(3, 'case "Contact Center":', spaces=2))
  1417. f.write(indented_str(4, 'nativeChannel.invokeMethod("openContactCenter");', spaces=2))
  1418. f.write(indented_str(4, "break;", spaces=2))
  1419. else:
  1420. f.write(indented_str(3, '// case "Contact Center":', spaces=2))
  1421. f.write(indented_str(4, '// nativeChannel.invokeMethod("openContactCenter");', spaces=2))
  1422. f.write(indented_str(4, "// break;", spaces=2))
  1423. if features["nc"]["status"]:
  1424. f.write(indented_str(3, 'case "Notification Center":', spaces=2))
  1425. f.write(indented_str(4, 'nativeChannel.invokeMethod("openNotificationCenter");', spaces=2))
  1426. f.write(indented_str(4, "break;", spaces=2))
  1427. else:
  1428. f.write(indented_str(3, '// case "Notification Center":', spaces=2))
  1429. f.write(indented_str(4, '// nativeChannel.invokeMethod("openNotificationCenter");', spaces=2))
  1430. f.write(indented_str(4, "// break;", spaces=2))
  1431. if features["im"]["status"]:
  1432. f.write(indented_str(3, 'case "Instant Messaging":', spaces=2))
  1433. f.write(indented_str(4, 'nativeChannel.invokeMethod("openInstantMessaging");', spaces=2))
  1434. f.write(indented_str(4, "break;", spaces=2))
  1435. else:
  1436. f.write(indented_str(3, '// case "Instant Messaging":', spaces=2))
  1437. f.write(indented_str(4, '// nativeChannel.invokeMethod("openInstantMessaging");', spaces=2))
  1438. f.write(indented_str(4, "// break;", spaces=2))
  1439. if features["call"]["status"]:
  1440. f.write(indented_str(3, 'case "Call":', spaces=2))
  1441. f.write(indented_str(4, 'nativeChannel.invokeMethod("openCall");', spaces=2))
  1442. f.write(indented_str(4, "break;", spaces=2))
  1443. else:
  1444. f.write(indented_str(3, '// case "Call":', spaces=2))
  1445. f.write(indented_str(4, '// nativeChannel.invokeMethod("openCall");', spaces=2))
  1446. f.write(indented_str(4, "// break;", spaces=2))
  1447. if features["ls"]["status"]:
  1448. f.write(indented_str(3, 'case "Streaming":', spaces=2))
  1449. f.write(indented_str(4, 'nativeChannel.invokeMethod("openStreaming");', spaces=2))
  1450. f.write(indented_str(4, "break;", spaces=2))
  1451. else:
  1452. f.write(indented_str(3, '// case "Streaming":', spaces=2))
  1453. f.write(indented_str(4, '// nativeChannel.invokeMethod("openStreaming");', spaces=2))
  1454. f.write(indented_str(4, "// break;", spaces=2))
  1455. else:
  1456. f.write(line)
  1457. with open(main_act_ios, "r") as f:
  1458. lines = f.readlines()
  1459. with open(main_act_ios, "w") as f:
  1460. for line in lines:
  1461. if "//FLOATING" in line:
  1462. if mode == "floating":
  1463. if features["cc"]["status"]:
  1464. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1465. else:
  1466. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1467. if features["nc"]["status"]:
  1468. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1469. else:
  1470. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1471. if features["im"]["status"]:
  1472. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1473. else:
  1474. f.write(indented_str(2,'// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1475. if features["call"]["status"]:
  1476. f.write(indented_str(2,'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1477. else:
  1478. f.write(indented_str(2,'// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1479. if features["ls"]["status"]:
  1480. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1481. else:
  1482. f.write(indented_str(2,'// Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1483. else:
  1484. f.write(indented_str(0, ""))
  1485. elif "APIS.connect" in line:
  1486. if mode == "floating":
  1487. replaced = line.replace("false", "true")
  1488. f.write(replaced)
  1489. else:
  1490. f.write(line)
  1491. else:
  1492. f.write(line)
  1493. elif platform == "ios_ionic":
  1494. main_act_path = os.path.join(path_dest, "src/app/app.component.ts")
  1495. main_act_ios = os.path.join(path_dest, "ios/App/App/AppDelegate.swift")
  1496. with open(main_act_path, "r") as f:
  1497. lines = f.readlines()
  1498. with open(main_act_path, "w") as f:
  1499. for line in lines:
  1500. if "//FEATURES" in line:
  1501. f.write(indented_str(4, '{', spaces=2))
  1502. f.write(indented_str(5, "text: 'Settings',", spaces=2))
  1503. f.write(indented_str(5, "handler: () => {", spaces=2))
  1504. f.write(indented_str(6, "this.openSettings();", spaces=2))
  1505. f.write(indented_str(5, "},", spaces=2))
  1506. f.write(indented_str(4, "},", spaces=2))
  1507. f.write(indented_str(4, '{', spaces=2))
  1508. f.write(indented_str(5, "text: 'Profile',", spaces=2))
  1509. f.write(indented_str(5, "handler: () => {", spaces=2))
  1510. f.write(indented_str(6, "this.openProfile();", spaces=2))
  1511. f.write(indented_str(5, "},", spaces=2))
  1512. f.write(indented_str(4, "},", spaces=2))
  1513. if features["cc"]["status"]:
  1514. f.write(indented_str(4, '{', spaces=2))
  1515. f.write(indented_str(5, "text: 'Contact Center',", spaces=2))
  1516. f.write(indented_str(5, "handler: () => {", spaces=2))
  1517. f.write(indented_str(6, "this.openContactCenter();", spaces=2))
  1518. f.write(indented_str(5, "},", spaces=2))
  1519. f.write(indented_str(4, "},", spaces=2))
  1520. else:
  1521. f.write(indented_str(4, '// {', spaces=2))
  1522. f.write(indented_str(5, "// text: 'Contact Center',", spaces=2))
  1523. f.write(indented_str(5, "// handler: () => {", spaces=2))
  1524. f.write(indented_str(6, "// this.openContactCenter();", spaces=2))
  1525. f.write(indented_str(5, "// },", spaces=2))
  1526. f.write(indented_str(4, "// },", spaces=2))
  1527. if features["nc"]["status"]:
  1528. f.write(indented_str(4, '{', spaces=2))
  1529. f.write(indented_str(5, "text: 'Notification Center',", spaces=2))
  1530. f.write(indented_str(5, "handler: () => {", spaces=2))
  1531. f.write(indented_str(6, "this.openNotificationCenter();", spaces=2))
  1532. f.write(indented_str(5, "},", spaces=2))
  1533. f.write(indented_str(4, "},", spaces=2))
  1534. else:
  1535. f.write(indented_str(4, '// {', spaces=2))
  1536. f.write(indented_str(5, "// text: 'Notification Center',", spaces=2))
  1537. f.write(indented_str(5, "// handler: () => {", spaces=2))
  1538. f.write(indented_str(6, "// this.openNotificationCenter();", spaces=2))
  1539. f.write(indented_str(5, "// },", spaces=2))
  1540. f.write(indented_str(4, "// },", spaces=2))
  1541. if features["im"]["status"]:
  1542. f.write(indented_str(4, '{', spaces=2))
  1543. f.write(indented_str(5, "text: 'Instant Messaging',", spaces=2))
  1544. f.write(indented_str(5, "handler: () => {", spaces=2))
  1545. f.write(indented_str(6, "this.openChat();", spaces=2))
  1546. f.write(indented_str(5, "},", spaces=2))
  1547. f.write(indented_str(4, "},", spaces=2))
  1548. else:
  1549. f.write(indented_str(4, '// {', spaces=2))
  1550. f.write(indented_str(5, "// text: 'Instant Messaging',", spaces=2))
  1551. f.write(indented_str(5, "// handler: () => {", spaces=2))
  1552. f.write(indented_str(6, "// this.openChat();", spaces=2))
  1553. f.write(indented_str(5, "// },", spaces=2))
  1554. f.write(indented_str(4, "// },", spaces=2))
  1555. if features["call"]["status"]:
  1556. f.write(indented_str(4, '{', spaces=2))
  1557. f.write(indented_str(5, "text: 'Call',", spaces=2))
  1558. f.write(indented_str(5, "handler: () => {", spaces=2))
  1559. f.write(indented_str(6, "this.openCall();", spaces=2))
  1560. f.write(indented_str(5, "},", spaces=2))
  1561. f.write(indented_str(4, "},", spaces=2))
  1562. else:
  1563. f.write(indented_str(4, '// {', spaces=2))
  1564. f.write(indented_str(5, "// text: 'Call',", spaces=2))
  1565. f.write(indented_str(5, "// handler: () => {", spaces=2))
  1566. f.write(indented_str(6, "// this.openCall();", spaces=2))
  1567. f.write(indented_str(5, "// },", spaces=2))
  1568. f.write(indented_str(4, "// },", spaces=2))
  1569. if features["ls"]["status"]:
  1570. f.write(indented_str(4, '{', spaces=2))
  1571. f.write(indented_str(5, "text: 'Streaming',", spaces=2))
  1572. f.write(indented_str(5, "handler: () => {", spaces=2))
  1573. f.write(indented_str(6, "this.openStreaming();", spaces=2))
  1574. f.write(indented_str(5, "},", spaces=2))
  1575. f.write(indented_str(4, "},", spaces=2))
  1576. else:
  1577. f.write(indented_str(4, '// {', spaces=2))
  1578. f.write(indented_str(5, "// text: 'Streaming',", spaces=2))
  1579. f.write(indented_str(5, "// handler: () => {", spaces=2))
  1580. f.write(indented_str(6, "// this.openStreaming();", spaces=2))
  1581. f.write(indented_str(5, "// },", spaces=2))
  1582. f.write(indented_str(4, "// },", spaces=2))
  1583. else:
  1584. f.write(line)
  1585. with open(main_act_ios, "r") as f:
  1586. lines = f.readlines()
  1587. with open(main_act_ios, "w") as f:
  1588. for line in lines:
  1589. if "//FLOATING" in line:
  1590. if mode == "floating":
  1591. if features["cc"]["status"]:
  1592. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1593. else:
  1594. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1595. if features["nc"]["status"]:
  1596. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1597. else:
  1598. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1599. if features["im"]["status"]:
  1600. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1601. else:
  1602. f.write(indented_str(2,'// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1603. if features["call"]["status"]:
  1604. f.write(indented_str(2,'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1605. else:
  1606. f.write(indented_str(2,'// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1607. if features["ls"]["status"]:
  1608. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1609. else:
  1610. f.write(indented_str(2,'// Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1611. else:
  1612. f.write(indented_str(0, ""))
  1613. elif "APIS.connect" in line:
  1614. if mode == "floating":
  1615. replaced = line.replace("false", "true")
  1616. f.write(replaced)
  1617. else:
  1618. f.write(line)
  1619. else:
  1620. f.write(line)
  1621. elif platform == "ios_react":
  1622. main_act_path = os.path.join(path_dest, "App.tsx")
  1623. main_act_ios = os.path.join(path_dest, "ios/CallNative.swift")
  1624. with open(main_act_path, "r") as f:
  1625. lines = f.readlines()
  1626. with open(main_act_path, "w") as f:
  1627. for line in lines:
  1628. if "'Features'" in line:
  1629. f.write(indented_str(4, "'Setting',", spaces=2))
  1630. f.write(indented_str(4, "'Profile',", spaces=2))
  1631. if features["cc"]["status"]:
  1632. f.write(indented_str(4, "'Contact Center',", spaces=2))
  1633. else:
  1634. f.write(indented_str(4, "// 'Contact Center',", spaces=2))
  1635. if features["nc"]["status"]:
  1636. f.write(indented_str(4, "'Notification Center',", spaces=2))
  1637. else:
  1638. f.write(indented_str(4, "// 'Notification Center',", spaces=2))
  1639. if features["im"]["status"]:
  1640. f.write(indented_str(4, "'Chat',", spaces=2))
  1641. else:
  1642. f.write(indented_str(4, "// 'Chat',", spaces=2))
  1643. if features["call"]["status"]:
  1644. f.write(indented_str(4, "'Call',", spaces=2))
  1645. else:
  1646. f.write(indented_str(4, "// 'Call',", spaces=2))
  1647. if features["ls"]["status"]:
  1648. f.write(indented_str(4, "'Live Streaming',", spaces=2))
  1649. else:
  1650. f.write(indented_str(4, "// 'Live Streaming',", spaces=2))
  1651. elif "//FEATURES1" in line:
  1652. n = 0
  1653. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1654. f.write(indented_str(6, "CallNative.openSetting();", spaces=2))
  1655. f.write(indented_str(5, "}", spaces=2))
  1656. n = n + 1
  1657. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1658. f.write(indented_str(6, "CallNative.openProfile();", spaces=2))
  1659. f.write(indented_str(5, "}", spaces=2))
  1660. n = n + 1
  1661. if features["cc"]["status"]:
  1662. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1663. f.write(indented_str(6, "CallNative.openContactCenter();", spaces=2))
  1664. f.write(indented_str(5, "}", spaces=2))
  1665. n = n + 1
  1666. else:
  1667. f.write(indented_str(5, "// if (buttonIndex === 2) {", spaces=2))
  1668. f.write(indented_str(6, "// CallNative.openContactCenter();", spaces=2))
  1669. f.write(indented_str(5, "// }", spaces=2))
  1670. if features["nc"]["status"]:
  1671. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1672. f.write(indented_str(6, "CallNative.openNotificationCenter();", spaces=2))
  1673. f.write(indented_str(5, "}", spaces=2))
  1674. n = n + 1
  1675. else:
  1676. f.write(indented_str(5, "// if (buttonIndex === 3) {", spaces=2))
  1677. f.write(indented_str(6, "// CallNative.openNotificationCenter();", spaces=2))
  1678. f.write(indented_str(5, "// }", spaces=2))
  1679. if features["im"]["status"]:
  1680. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1681. f.write(indented_str(6, "CallNative.openChat();", spaces=2))
  1682. f.write(indented_str(5, "}", spaces=2))
  1683. n = n + 1
  1684. else:
  1685. f.write(indented_str(5, "// if (buttonIndex === 4) {", spaces=2))
  1686. f.write(indented_str(6, "// CallNative.openChat();", spaces=2))
  1687. f.write(indented_str(5, "// }", spaces=2))
  1688. if features["call"]["status"]:
  1689. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1690. f.write(indented_str(6, "CallNative.openCall();", spaces=2))
  1691. f.write(indented_str(5, "}", spaces=2))
  1692. n = n + 1
  1693. else:
  1694. f.write(indented_str(5, "// if (buttonIndex === 5) {", spaces=2))
  1695. f.write(indented_str(6, "// CallNative.openCall();", spaces=2))
  1696. f.write(indented_str(5, "// }", spaces=2))
  1697. if features["ls"]["status"]:
  1698. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1699. f.write(indented_str(6, "CallNative.openStreaming();", spaces=2))
  1700. f.write(indented_str(5, "}", spaces=2))
  1701. n = n + 1
  1702. else:
  1703. f.write(indented_str(5, "// if (buttonIndex === 6) {", spaces=2))
  1704. f.write(indented_str(6, "// CallNative.openStreaming();", spaces=2))
  1705. f.write(indented_str(5, "// }", spaces=2))
  1706. elif "//FEATURES2" in line:
  1707. n = 0
  1708. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1709. f.write(indented_str(3, "try {", spaces=2))
  1710. f.write(indented_str(4, "CallNative.openSetting();", spaces=2))
  1711. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1712. f.write(indented_str(4, "console.log(e);", spaces=2))
  1713. f.write(indented_str(3, "}", spaces=2))
  1714. f.write(indented_str(2, "}", spaces=2))
  1715. n = n + 1
  1716. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1717. f.write(indented_str(3, "try {", spaces=2))
  1718. f.write(indented_str(4, "CallNative.openProfile();", spaces=2))
  1719. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1720. f.write(indented_str(4, "console.log(e);", spaces=2))
  1721. f.write(indented_str(3, "}", spaces=2))
  1722. f.write(indented_str(2, "}", spaces=2))
  1723. n = n + 1
  1724. if features["cc"]["status"]:
  1725. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1726. f.write(indented_str(3, "try {", spaces=2))
  1727. f.write(indented_str(4, "CallNative.openContactCenter();", spaces=2))
  1728. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1729. f.write(indented_str(4, "console.log(e);", spaces=2))
  1730. f.write(indented_str(3, "}", spaces=2))
  1731. f.write(indented_str(2, "}", spaces=2))
  1732. n = n + 1
  1733. else:
  1734. f.write(indented_str(2, "// if (buttonIndex === 2) {", spaces=2))
  1735. f.write(indented_str(3, "// try {", spaces=2))
  1736. f.write(indented_str(4, "// CallNative.openContactCenter();", spaces=2))
  1737. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1738. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1739. f.write(indented_str(3, "// }", spaces=2))
  1740. f.write(indented_str(2, "// }", spaces=2))
  1741. if features["nc"]["status"]:
  1742. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1743. f.write(indented_str(3, "try {", spaces=2))
  1744. f.write(indented_str(4, "CallNative.openNotificationCenter();", spaces=2))
  1745. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1746. f.write(indented_str(4, "console.log(e);", spaces=2))
  1747. f.write(indented_str(3, "}", spaces=2))
  1748. f.write(indented_str(2, "}", spaces=2))
  1749. n = n + 1
  1750. else:
  1751. f.write(indented_str(2, "// if (buttonIndex === 3) {", spaces=2))
  1752. f.write(indented_str(3, "// try {", spaces=2))
  1753. f.write(indented_str(4, "// CallNative.openNotificationCenter();", spaces=2))
  1754. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1755. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1756. f.write(indented_str(3, "// }", spaces=2))
  1757. f.write(indented_str(2, "// }", spaces=2))
  1758. if features["im"]["status"]:
  1759. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1760. f.write(indented_str(3, "try {", spaces=2))
  1761. f.write(indented_str(4, "CallNative.openChat();", spaces=2))
  1762. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1763. f.write(indented_str(4, "console.log(e);", spaces=2))
  1764. f.write(indented_str(3, "}", spaces=2))
  1765. f.write(indented_str(2, "}", spaces=2))
  1766. n = n + 1
  1767. else:
  1768. f.write(indented_str(2, "// if (buttonIndex === 4) {", spaces=2))
  1769. f.write(indented_str(3, "// try {", spaces=2))
  1770. f.write(indented_str(4, "// CallNative.openChat();", spaces=2))
  1771. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1772. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1773. f.write(indented_str(3, "// }", spaces=2))
  1774. f.write(indented_str(2, "// }", spaces=2))
  1775. if features["call"]["status"]:
  1776. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1777. f.write(indented_str(3, "try {", spaces=2))
  1778. f.write(indented_str(4, "CallNative.openCall();", spaces=2))
  1779. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1780. f.write(indented_str(4, "console.log(e);", spaces=2))
  1781. f.write(indented_str(3, "}", spaces=2))
  1782. f.write(indented_str(2, "}", spaces=2))
  1783. n = n + 1
  1784. else:
  1785. f.write(indented_str(2, "// if (buttonIndex === 5) {", spaces=2))
  1786. f.write(indented_str(3, "// try {", spaces=2))
  1787. f.write(indented_str(4, "// CallNative.openCall();", spaces=2))
  1788. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1789. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1790. f.write(indented_str(3, "// }", spaces=2))
  1791. f.write(indented_str(2, "// }", spaces=2))
  1792. if features["ls"]["status"]:
  1793. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1794. f.write(indented_str(3, "try {", spaces=2))
  1795. f.write(indented_str(4, "CallNative.openStreaming();", spaces=2))
  1796. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1797. f.write(indented_str(4, "console.log(e);", spaces=2))
  1798. f.write(indented_str(3, "}", spaces=2))
  1799. f.write(indented_str(2, "}", spaces=2))
  1800. n = n + 1
  1801. else:
  1802. f.write(indented_str(2, "// if (buttonIndex === {n}) {", spaces=2))
  1803. f.write(indented_str(3, "// try {", spaces=2))
  1804. f.write(indented_str(4, "// CallNative.openStreaming();", spaces=2))
  1805. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1806. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1807. f.write(indented_str(3, "// }", spaces=2))
  1808. f.write(indented_str(2, "// }", spaces=2))
  1809. elif "//FEATURES3" in line:
  1810. n = 0
  1811. f.write(indented_str(5, "<Button", spaces=2))
  1812. f.write(indented_str(6, 'title="Setting"', spaces=2))
  1813. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1814. f.write(indented_str(5, "/>", spaces=2))
  1815. n = n + 1
  1816. f.write(indented_str(5, "<Button", spaces=2))
  1817. f.write(indented_str(6, 'title="Profile"', spaces=2))
  1818. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1819. f.write(indented_str(5, "/>", spaces=2))
  1820. n = n + 1
  1821. if features["cc"]["status"]:
  1822. f.write(indented_str(5, "<Button", spaces=2))
  1823. f.write(indented_str(6, 'title="Contact Center"', spaces=2))
  1824. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1825. f.write(indented_str(5, "/>", spaces=2))
  1826. n = n + 1
  1827. else:
  1828. f.write(indented_str(5, "{/* <Button", spaces=2))
  1829. f.write(indented_str(6, 'title="Contact Center"', spaces=2))
  1830. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(2)}}', spaces=2))
  1831. f.write(indented_str(5, "/> */}", spaces=2))
  1832. if features["nc"]["status"]:
  1833. f.write(indented_str(5, "<Button", spaces=2))
  1834. f.write(indented_str(6, 'title="Notification Center"', spaces=2))
  1835. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1836. f.write(indented_str(5, "/>", spaces=2))
  1837. n = n + 1
  1838. else:
  1839. f.write(indented_str(5, "{/* <Button", spaces=2))
  1840. f.write(indented_str(6, 'title="Notification Center"', spaces=2))
  1841. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(3)}}', spaces=2))
  1842. f.write(indented_str(5, "/> */}", spaces=2))
  1843. if features["im"]["status"]:
  1844. f.write(indented_str(5, "<Button", spaces=2))
  1845. f.write(indented_str(6, 'title="Chat"', spaces=2))
  1846. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1847. f.write(indented_str(5, "/>", spaces=2))
  1848. n = n + 1
  1849. else:
  1850. f.write(indented_str(5, "{/* <Button", spaces=2))
  1851. f.write(indented_str(6, 'title="Chat"', spaces=2))
  1852. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(4)}}', spaces=2))
  1853. f.write(indented_str(5, "/> */}", spaces=2))
  1854. if features["call"]["status"]:
  1855. f.write(indented_str(5, "<Button", spaces=2))
  1856. f.write(indented_str(6, 'title="Call"', spaces=2))
  1857. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1858. f.write(indented_str(5, "/>", spaces=2))
  1859. n = n + 1
  1860. else:
  1861. f.write(indented_str(5, "{/* <Button", spaces=2))
  1862. f.write(indented_str(6, 'title="Call"', spaces=2))
  1863. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(5)}}', spaces=2))
  1864. f.write(indented_str(5, "/> */}", spaces=2))
  1865. if features["ls"]["status"]:
  1866. f.write(indented_str(5, "<Button", spaces=2))
  1867. f.write(indented_str(6, 'title="Live Streaming"', spaces=2))
  1868. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1869. f.write(indented_str(5, "/>", spaces=2))
  1870. n = n + 1
  1871. else:
  1872. f.write(indented_str(5, "{/* <Button", spaces=2))
  1873. f.write(indented_str(6, 'title="Live Streaming"', spaces=2))
  1874. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(5)}}', spaces=2))
  1875. f.write(indented_str(5, "/> */}", spaces=2))
  1876. else:
  1877. f.write(line)
  1878. with open(main_act_ios, "r") as f:
  1879. lines = f.readlines()
  1880. with open(main_act_ios, "w") as f:
  1881. for line in lines:
  1882. if "//FLOATING" in line:
  1883. if mode == "floating":
  1884. if features["cc"]["status"]:
  1885. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1886. else:
  1887. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1888. if features["nc"]["status"]:
  1889. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1890. else:
  1891. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1892. if features["im"]["status"]:
  1893. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1894. else:
  1895. f.write(indented_str(2,'// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1896. if features["call"]["status"]:
  1897. f.write(indented_str(2,'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1898. else:
  1899. f.write(indented_str(2,'// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1900. if features["ls"]["status"]:
  1901. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1902. else:
  1903. f.write(indented_str(2,'// Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1904. else:
  1905. f.write(indented_str(0, ""))
  1906. elif "APIS.connect" in line:
  1907. if mode == "floating":
  1908. replaced = line.replace("false", "true")
  1909. f.write(replaced)
  1910. else:
  1911. f.write(line)
  1912. else:
  1913. f.write(line)
  1914. def deliver_zip(path_dest, uid):
  1915. rand_name = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(32))
  1916. zip_name = f"{rand_name}"
  1917. new_dir = os.path.join(app.zip_folder, zip_name)
  1918. try:
  1919. shutil.make_archive(new_dir, 'zip', path_dest)
  1920. project_path = os.path.join(app.temp_folder, uid)
  1921. shutil.rmtree(project_path)
  1922. return {"status": "0", "name": zip_name + ".zip"}
  1923. except Exception as e:
  1924. return {"status": "4", "message": "Deliver ZIP failed"}
  1925. @app.route('/', methods=["GET", "POST"])
  1926. def build_project():
  1927. vprint('==============================================================')
  1928. if request.method == 'POST':
  1929. platform = "android"
  1930. mode = "burger"
  1931. app_id = ""
  1932. feature_dict = {
  1933. "im": {
  1934. "status": False
  1935. },
  1936. "cc": {
  1937. "status": False
  1938. },
  1939. "call": {
  1940. "status": False
  1941. },
  1942. "ls": {
  1943. "status": False
  1944. },
  1945. "settings": {
  1946. "status": False
  1947. },
  1948. "nc": {
  1949. "status": False
  1950. },
  1951. "sms": {
  1952. "status": False
  1953. },
  1954. "email": {
  1955. "status": False
  1956. },
  1957. "smartbot": {
  1958. "status": False
  1959. }
  1960. }
  1961. security_dict = {
  1962. "root_device": False,
  1963. "malware": False,
  1964. "clone": False,
  1965. "emulator": False,
  1966. "debug": False,
  1967. "sim_swap": False,
  1968. "capture": False,
  1969. "call_forwarding": False,
  1970. "secure_folder": False,
  1971. "show_security": False,
  1972. "screen_share": False,
  1973. "side_load": False,
  1974. "key_logger": False,
  1975. }
  1976. try:
  1977. if "feature_im" in request.form:
  1978. feature_dict["im"]["status"] = request.form["feature_im"] == "1"
  1979. if "feature_cc" in request.form:
  1980. feature_dict["cc"]["status"] = request.form["feature_cc"] == "1"
  1981. if "feature_vc" in request.form:
  1982. feature_dict["call"]["status"] = request.form["feature_vc"] == "1"
  1983. if "feature_ac" in request.form and not feature_dict["call"]["status"]:
  1984. feature_dict["call"]["status"] = request.form["feature_ac"] == "1"
  1985. if "feature_ls" in request.form:
  1986. feature_dict["ls"]["status"] = request.form["feature_ls"] == "1"
  1987. if "feature_nc" in request.form:
  1988. feature_dict["nc"]["status"] = request.form["feature_nc"] == "1"
  1989. if "feature_sms" in request.form:
  1990. feature_dict["sms"]["status"] = request.form["feature_sms"] == "1"
  1991. if "feature_email" in request.form:
  1992. feature_dict["email"]["status"] = request.form["feature_email"] == "1"
  1993. if "feature_smartbot" in request.form:
  1994. feature_dict["smartbot"]["status"] = request.form["feature_smartbot"] == "1"
  1995. if "feature_settings" in request.form:
  1996. feature_dict["settings"]["status"] = request.form["feature_settings"] == "1"
  1997. if "security_malware" in request.form:
  1998. security_dict["malware"] = request.form["security_malware"] == "1"
  1999. if "security_clone" in request.form:
  2000. security_dict["clone"] = request.form["security_clone"] == "1"
  2001. if "security_emulator" in request.form:
  2002. security_dict["emulator"] = request.form["security_emulator"] == "1"
  2003. if "security_debug" in request.form:
  2004. security_dict["debug"] = request.form["security_debug"] == "1"
  2005. if "security_sim_swap" in request.form:
  2006. security_dict["sim_swap"] = request.form["security_sim_swap"] == "1"
  2007. if "security_capture" in request.form:
  2008. security_dict["capture"] = request.form["security_capture"] == "1"
  2009. if "security_call_forwarding" in request.form:
  2010. security_dict["call_forwarding"] = request.form["security_call_forwarding"] == "1"
  2011. if "security_secure_folder" in request.form:
  2012. security_dict["secure_folder"] = request.form["security_secure_folder"] == "1"
  2013. if "show_security" in request.form:
  2014. security_dict["show_security"] = request.form["show_security"] == "1"
  2015. if "security_rootdevice" in request.form:
  2016. security_dict["root_device"] = request.form["security_rootdevice"] == "1"
  2017. if "security_screenshare" in request.form:
  2018. security_dict["screen_share"] = request.form["security_screenshare"] == "1"
  2019. if "security_sideloaded" in request.form:
  2020. security_dict["side_load"] = request.form["security_sideloaded"] == "1"
  2021. if "security_keylogger" in request.form:
  2022. security_dict["key_logger"] = request.form["security_keylogger"] == "1"
  2023. security_dict["show_security"] = (security_dict["malware"] or security_dict["clone"]
  2024. or security_dict["emulator"] or security_dict["debug"]
  2025. or security_dict["sim_swap"] or security_dict["capture"]
  2026. or security_dict["call_forwarding"]
  2027. or security_dict["secure_folder"])
  2028. if "platform" in request.form:
  2029. platform = request.form["platform"]
  2030. if "mode" in request.form:
  2031. mode = request.form["mode"]
  2032. if "app_id" in request.form:
  2033. app_id = request.form["app_id"]
  2034. except BaseException as e:
  2035. vprint(traceback.format_exc())
  2036. return {"status": "1", "message": "Parameter mismatch\n{}\n".format(str(e))}, 400
  2037. try:
  2038. uu_id = str(uuid.uuid4())
  2039. path_dest = create_folder(platform, uu_id)
  2040. change(app_id, platform, mode, path_dest, feature_dict, security_dict)
  2041. return deliver_zip(path_dest, uu_id)
  2042. except BaseException as e:
  2043. vprint(traceback.format_exc())
  2044. return {"status": "2", "message": "Process failure\n{}\n".format(str(e))}, 200
  2045. else:
  2046. if 'e' in request.args:
  2047. return request.args['e']
  2048. return "Hello World!"
  2049. if __name__ == '__main__':
  2050. app.run(host='0.0.0.0', port=8056, debug=app.verbose, ssl_context=app.ssl)