main.py 121 KB

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