main.py 91 KB

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