main.py 112 KB

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