main.py 122 KB

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