main.py 106 KB

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