main.py 99 KB

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