main.py 125 KB

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