main.py 107 KB

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