-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisync.py
More file actions
2356 lines (2204 loc) · 102 KB
/
Copy pathisync.py
File metadata and controls
2356 lines (2204 loc) · 102 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os
import threading
import tkinter as tk
from tkinter import filedialog ,messagebox ,simpledialog
from tkinter import ttk
from tkinter .scrolledtext import ScrolledText
import tempfile
import time
import zipfile
import shutil
import urllib .request
import json
import plistlib
# third-party
try :
import paramiko
except ImportError :
paramiko =None
try :
from PIL import Image # type: ignore
except Exception :
Image =None
try :
from tkinterdnd2 import DND_FILES ,TkinterDnD # type: ignore
_DND_AVAILABLE =True
except Exception :
DND_FILES =None
TkinterDnD =None
_DND_AVAILABLE =False
# local
ExplorerFrame =None
try :
# prefer new module name
from ixplorer_frame import ExplorerFrame # type: ignore
except Exception :
try :
from isyncexplorer import ExplorerFrame # type: ignore
except Exception :
ExplorerFrame =None
class IPAGui ((TkinterDnD .Tk if _DND_AVAILABLE else tk .Tk )):
def __init__ (self ):
super ().__init__ ()
self .title ("iPhone IPA Installer")
# size to comfortably fit all controls without scrolling
self .geometry ("900x720")
self .resizable (True ,True )
# professional look and sane minimums
try :
self .minsize (920 ,700 )
style =ttk .Style ()
if 'vista' in style .theme_names ():
style .theme_use ('vista')
elif 'clam' in style .theme_names ():
style .theme_use ('clam')
except Exception :
pass
self .ipa_path =tk .StringVar ()
self .iphone_ip =tk .StringVar ()
self .iphone_port =tk .IntVar (value =22 )
self .username =tk .StringVar (value ="root")
self .password =tk .StringVar ()
# histories for dropdowns
self ._ip_history =["192.168.178.67"]
self ._user_history =["root"]
self ._key_history =[]
self ._ipa_history =[]
self ._appdir_history =[]
self .app_dir_path =tk .StringVar ()
# auth type: rsa dss both
self .auth_choice =tk .StringVar (value ="Both")
# use password too default true globally
self .use_password =tk .BooleanVar (value =True )
self .private_key_path =tk .StringVar ()
# raw output mode for ipainstaller no extra messages
self .raw_output =tk .BooleanVar (value =True )
# commands-only mode: only show the commands we run no outputs
self .commands_only =tk .BooleanVar (value =True )
# preferences
self .no_respring =tk .BooleanVar (value =False )
# installer choice: ipainstaller or appinst appinst not implemented yet
self .installer_choice =tk .StringVar (value ="ipainstaller")
# ipainstaller flags
self .flags ={
'-a':tk .BooleanVar (value =False ),
'-b':tk .BooleanVar (value =False ),
'-B':tk .BooleanVar (value =False ),
'-c':tk .BooleanVar (value =False ),
'-d':tk .BooleanVar (value =False ),
'-f':tk .BooleanVar (value =False ),
'-h':tk .BooleanVar (value =False ),
'-i':tk .BooleanVar (value =False ),
'-l':tk .BooleanVar (value =False ),
'-n':tk .BooleanVar (value =False ),
'-o':tk .BooleanVar (value =False ),
'-q':tk .BooleanVar (value =False ),
'-Q':tk .BooleanVar (value =False ),
'-r':tk .BooleanVar (value =False ),
'-u':tk .BooleanVar (value =False ),
}
# args for flags that need them
self .flag_args ={
'-b':tk .StringVar (),# app_id
'-B':tk .StringVar (),# app_id
'-i':tk .StringVar (),# app_ids
'-o':tk .StringVar (),# output_path
'-u':tk .StringVar (),# app_ids
}
# command previews
self .command_preview =tk .StringVar (value ="")
self .jf_command_preview =tk .StringVar (value ="")
# presets and profiles
self .preset_name =tk .StringVar (value ="")
self .profiles ={} # name -> dict of connection fields
self .profile_name =tk .StringVar (value ="")
self .last_preset =tk .StringVar (value ="")
# status bar
self .status_text =tk .StringVar (value ="Ready")
self .status_device =tk .StringVar (value ="")
# status led internals
self ._led_canvas =None
self ._led_item =None
self ._led_anim_job =None
self ._led_on =False
self ._build_ui ()
# try to load settings after ui created to populate combos
try :
self ._load_settings ()
except Exception :
pass
# save settings on close
self .protocol ("WM_DELETE_WINDOW",self ._on_close )
# ensure geometry/layout is realized on first show
try :
self .update_idletasks ()
except Exception :
pass
# init command preview traces and compute initial preview
try :
self ._init_validation_styles ()
self ._init_command_preview_traces ()
self ._update_command_preview ()
self ._init_command_preview_traces ()
self ._update_command_preview ()
self ._init_jf_command_preview_traces ()
self ._update_jf_command_preview ()
except Exception :
pass
# initialize icons static + animated
try :
self ._init_icon_system ()
except Exception :
# dont crash ui if icon init fails
pass
# -----------------------------
# icon system static + animated
# -----------------------------
# keyboard shortcuts
try :
self ._init_shortcuts ()
except Exception :
pass
def _asset_base (self ):
try :
return os .path .dirname (os .path .abspath (__file__ ))
except Exception :
return os .getcwd ()
# -----------------------------
# settings persistence + close
# -----------------------------
def _settings_path (self ):
try :
base =self ._asset_base ()
return os .path .join (base ,"settings.json")
except Exception :
return "settings.json"
def _save_settings (self ):
try :
data ={
"connection":{
"iphone_ip":self .iphone_ip .get (),
"iphone_port":int (self .iphone_port .get ()or 22 ),
"username":self .username .get (),
"use_password":bool (self .use_password .get ()),
"private_key_path":self .private_key_path .get (),
# do not save plaintext password by default
},
"ui":{
"installer_choice":self .installer_choice .get (),
"raw_output":bool (self .raw_output .get ()),
"commands_only":bool (self .commands_only .get ()),
"no_respring":bool (self .no_respring .get ()),
"geometry":self .geometry (),
},
"flags":{k :bool (v .get ())for k ,v in self .flags .items ()},
"flag_args":{k :v .get ()for k ,v in self .flag_args .items ()},
"histories":{
"ip":self ._ip_history ,
"user":self ._user_history ,
"key":self ._key_history ,
"ipa":self ._ipa_history ,
"appdir":self ._appdir_history ,
},
"profiles":self .profiles ,
"last_preset":self .last_preset .get (),
"selected_profile":self .profile_name .get (),
}
with open (self ._settings_path (),'w',encoding ='utf-8')as f :
json .dump (data ,f ,ensure_ascii =False ,indent =2 )
except Exception :
# non-fatal
pass
def _load_settings (self ):
try :
sp =self ._settings_path ()
if not os .path .exists (sp ):
return
with open (sp ,'r',encoding ='utf-8')as f :
data =json .load (f )
c =data .get ("connection",{})
self .iphone_ip .set (c .get ("iphone_ip",self .iphone_ip .get ()))
self .iphone_port .set (int (c .get ("iphone_port",self .iphone_port .get ()or 22 )))
self .username .set (c .get ("username",self .username .get ()))
self .use_password .set (bool (c .get ("use_password",self .use_password .get ())))
self .private_key_path .set (c .get ("private_key_path",self .private_key_path .get ()))
ui =data .get ("ui",{})
self .installer_choice .set (ui .get ("installer_choice",self .installer_choice .get ()))
self .raw_output .set (bool (ui .get ("raw_output",self .raw_output .get ())))
self .commands_only .set (bool (ui .get ("commands_only",self .commands_only .get ())))
self .no_respring .set (bool (ui .get ("no_respring",self .no_respring .get ())))
try :
geom =ui .get ("geometry")
if geom :
self .geometry (geom )
except Exception :
pass
fl =data .get ("flags",{})
for k ,v in fl .items ():
if k in self .flags :
try :
self .flags [k ].set (bool (v ))
except Exception :
pass
fla =data .get ("flag_args",{})
for k ,v in fla .items ():
if k in self .flag_args :
try :
self .flag_args [k ].set (str (v ))
except Exception :
pass
his =data .get ("histories",{})
self ._ip_history =list (his .get ("ip",self ._ip_history ))
self ._user_history =list (his .get ("user",self ._user_history ))
self ._key_history =list (his .get ("key",self ._key_history ))
self ._ipa_history =list (his .get ("ipa",self ._ipa_history ))
self ._appdir_history =list (his .get ("appdir",self ._appdir_history ))
# profiles/presets
self .profiles =dict (data .get ("profiles",{}))
self .last_preset .set (data .get ("last_preset",self .last_preset .get ()))
self .profile_name .set (data .get ("selected_profile",self .profile_name .get ()))
# refresh combos with new histories
try :
self ._refresh_combos ()
except Exception :
pass
except Exception :
# non-fatal
pass
def _on_close (self ):
try :
self ._save_settings ()
except Exception :
pass
try :
# stop animation and cleanup temp icon dir
try :
self ._stop_icon_animation ()
except Exception :
pass
tmp =getattr (self ,"_icon_tempdir",None )
if tmp and os .path .exists (tmp ):
try :
shutil .rmtree (tmp ,ignore_errors =True )
except Exception :
pass
finally :
try :
self .destroy ()
except Exception :
pass
# -----------------------------
# command preview + test ssh
# -----------------------------
def _init_command_preview_traces (self ):
# attach traces to update command preview when inputs change
def attach (var ):
try :
var .trace_add ("write",lambda *a :self ._update_command_preview ())
except Exception :
pass
attach (self .ipa_path )
attach (self .iphone_ip )
attach (self .iphone_port )
attach (self .username )
attach (self .password )
attach (self .use_password )
attach (self .private_key_path )
attach (self .installer_choice )
for v in self .flags .values ():
attach (v )
for v in self .flag_args .values ():
attach (v )
def _update_command_preview (self ):
try :
# try to leverage existing arg collection if available
try :
args =self ._collect_ipainstaller_args ()
if isinstance (args ,list ):
cmd =" ".join (self ._shell_quote (a )for a in args )
else :
cmd =str (args )
except Exception :
# fallback minimal reconstruction
parts =[self .installer_choice .get ()or "ipainstaller"]
for k ,v in self .flags .items ():
if v .get ():
parts .append (k )
for k ,v in self .flag_args .items ():
val =v .get ().strip ()
if val :
parts .extend ([k ,val ])
ipa =self .ipa_path .get ().strip ()
if ipa :
parts .append (ipa )
cmd =" ".join (self ._shell_quote (p )for p in parts )
self .command_preview .set (cmd )
except Exception :
# never crash ui
pass
def _init_jf_command_preview_traces (self ):
# attach traces to update jf command preview when inputs change
def attach (var ):
try :
var .trace_add ("write",lambda *a :self ._update_jf_command_preview ())
except Exception :
pass
attach (self .ipa_path )
try :
attach (self .app_dir_path )
except Exception :
pass
attach (self .iphone_ip )
attach (self .iphone_port )
attach (self .username )
attach (self .use_password )
attach (self .private_key_path )
def _update_jf_command_preview (self ):
# build a simple jailfr3e command preview
try :
ipa = (self .ipa_path .get ()or "").strip ()
appdir = (getattr (self ,'app_dir_path',tk .StringVar (value ="")).get ()or "").strip ()
if ipa :
cmd =f"jailfr3e install {self._shell_quote(ipa)}"
elif appdir :
cmd =f"jailfr3e appdrop {self._shell_quote(appdir)}"
else :
cmd ="jailfr3e"
self .jf_command_preview .set (cmd )
except Exception :
pass
def _on_test_ssh (self ):
def run ():
try :
client =self ._connect ()
try :
if not self .commands_only .get ():
self ._log ("SSH test: Connected successfully.")
messagebox .showinfo ("SSH","Connected successfully.")
finally :
try :
client .close ()
except Exception :
pass
except Exception as e :
if not self .commands_only .get ():
self ._log (f"SSH test failed: {e}")
messagebox .showerror ("SSH Test Failed",str (e ))
try :
self ._run_with_icon_anim (run )
except Exception :
# fallback without animation
run ()
# -----------------------------
# validation + status bar
# -----------------------------
def _is_valid_ip (self ,ip :str ):
try :
parts =ip .split ('.')
if len (parts )!=4 :
return False
for p in parts :
if not p .isdigit ():
return False
v =int (p )
if v <0 or v >255 :
return False
return True
except Exception :
return False
def _validate_ui (self ):
# returns (ok, message)
ip =self .iphone_ip .get ().strip ()
ipa =self .ipa_path .get ().strip ()
use_pw =bool (self .use_password .get ())
key =self .private_key_path .get ().strip ()
try :
port =int (self .iphone_port .get ()or 0 )
except Exception :
port =0
if not ip or not self ._is_valid_ip (ip ):
return False ,"enter a valid ip address"
if port <=0 or port >65535 :
return False ,"enter a valid port"
if not ipa :
return False ,"choose an ipa file"
if not use_pw and not key :
return False ,"provide a private key or enable password"
if key and not os .path .exists (key ):
return False ,"private key path not found"
return True ,"ready"
def _apply_validation (self ):
# clear any previous styles
try :
self ._clear_invalids ()
except Exception :
pass
# granular checks for targeted highlighting
ip =self .iphone_ip .get ().strip ()
ipa =self .ipa_path .get ().strip ()
use_pw =bool (self .use_password .get ())
key =self .private_key_path .get ().strip ()
try :
port =int (self .iphone_port .get ()or 0 )
except Exception :
port =0
ok =True
msg ="ready"
if not ip or not self ._is_valid_ip (ip ):
ok =False
msg ="enter a valid ip address"
self ._mark_invalid (getattr (self ,'ip_combo',None ),'combo',msg )
elif port <=0 or port >65535 :
ok =False
msg ="enter a valid port"
self ._mark_invalid (getattr (self ,'port_entry',None ),'entry',msg )
elif not ipa :
ok =False
msg ="choose an ipa file"
self ._mark_invalid (getattr (self ,'ipa_combo',None ),'combo',msg )
elif (not use_pw )and (not key ):
ok =False
msg ="provide a private key or enable password"
self ._mark_invalid (getattr (self ,'key_combo',None ),'combo',msg )
elif key and not os .path .exists (key ):
ok =False
msg ="private key path not found"
self ._mark_invalid (getattr (self ,'key_combo',None ),'combo',msg )
# apply enabled state to buttons
for btn in [getattr (self ,'install_btn',None ),getattr (self ,'run_ipainstaller_btn',None ),getattr (self ,'jf_install_btn',None )]:
try :
if btn is not None :
btn .configure (state =(tk .NORMAL if ok else tk .DISABLED ))
except Exception :
pass
self ._set_status (msg )
def _init_validation_traces (self ):
def attach (var ):
try :
var .trace_add ("write",lambda *a :self ._apply_validation ())
except Exception :
pass
attach (self .iphone_ip )
attach (self .iphone_port )
attach (self .ipa_path )
attach (self .use_password )
attach (self .private_key_path )
def _set_status (self ,text :str ):
try :
self .status_text .set (text )
self .status_device .set (f"{self.iphone_ip.get()}:{self.iphone_port.get()}")
except Exception :
pass
def _init_shortcuts (self ):
try :
# file open
self .bind ("<Control-o>",lambda e :self ._choose_ipa ())
self .bind ("<Control-O>",lambda e :self ._choose_ipa ())
# install
self .bind ("<Control-i>",lambda e :self ._on_install_click ())
self .bind ("<Control-I>",lambda e :self ._on_install_click ())
# clear output
self .bind ("<Control-l>",lambda e :self ._clear_output ())
self .bind ("<Control-L>",lambda e :self ._clear_output ())
# respring
self .bind ("<F5>",lambda e :self ._on_respring ())
except Exception :
pass
def _enter_busy (self ,msg ="Working…"):
try :
self ._set_status (msg )
# visual busy cursor
self .configure (cursor ="watch")
# disable primary action buttons while running
for btn in [getattr (self ,'install_btn',None ),getattr (self ,'run_ipainstaller_btn',None ),getattr (self ,'jf_install_btn',None )]:
try :
if btn is not None :
btn .configure (state =tk .DISABLED )
except Exception :
pass
# start status led pulse
try :
self ._start_led_anim ()
except Exception :
pass
except Exception :
pass
def _leave_busy (self ):
try :
self .configure (cursor ="")
# re-apply validation to restore correct enabled state
self ._apply_validation ()
self ._set_status ("Ready")
try :
self ._stop_led_anim ()
except Exception :
pass
except Exception :
pass
def _init_icon_system (self ):
# state
self ._icon_fps =30
self ._icon_anim_job =None
self ._icon_anim_running =False
self ._icon_frame_index =0
self ._icon_frames =[]# list[tkphotoimage]
self ._icon_tempdir =tempfile .mkdtemp (prefix ="isync_icon_")
# paths
self ._icon_static_path =os .path .join (self ._asset_base (),"imgtitle.png")
self ._icon_gif_path =os .path .join (self ._asset_base (),"process_img.gif")
# load static icon
self ._set_static_icon ()
# prepare animation frames
self ._prepare_animation_frames ()
def _set_static_icon (self ):
try :
if os .path .isfile (self ._icon_static_path ):
self ._icon_static_img =tk .PhotoImage (file =self ._icon_static_path )
self .iconphoto (True ,self ._icon_static_img )
except Exception :
pass
def _prepare_animation_frames (self ):
# clear any existing
self ._icon_frames =[]
self ._icon_frame_index =0
if not os .path .isfile (self ._icon_gif_path ):
return
try :
if Image is not None :
# extract frames to png files in temp then load as photoimage
with Image .open (self ._icon_gif_path )as im :
frame_idx =0
while True :
im .seek (frame_idx )
frame =im .convert ("RGBA")
out_path =os .path .join (self ._icon_tempdir ,f"frame_{frame_idx:03d}.png")
frame .save (out_path ,format ="PNG")
try :
self ._icon_frames .append (tk .PhotoImage (file =out_path ))
except Exception :
break
frame_idx +=1
else :
# fallback without pillow: load gif frames directly no png extraction
idx =0
while True :
try :
frm =tk .PhotoImage (file =self ._icon_gif_path ,format =f"gif -index {idx}")
self ._icon_frames .append (frm )
idx +=1
except Exception :
break
except Exception :
# ignore errors keep static icon only
self ._icon_frames =[]
def _animate_tick (self ):
if not self ._icon_anim_running or not self ._icon_frames :
return
try :
img =self ._icon_frames [self ._icon_frame_index %len (self ._icon_frames )]
self .iconphoto (True ,img )
self ._icon_frame_index =(self ._icon_frame_index +1 )%len (self ._icon_frames )
except Exception :
# stop animation on error
self ._icon_anim_running =False
self ._set_static_icon ()
return
# schedule next frame
delay =int (1000 /max (1 ,self ._icon_fps ))
self ._icon_anim_job =self .after (delay ,self ._animate_tick )
def _start_icon_animation (self ):
if self ._icon_anim_running :
return
if not self ._icon_frames :
return
self ._icon_anim_running =True
self ._icon_frame_index =0
# start on ui thread
self .after (0 ,self ._animate_tick )
def _stop_icon_animation (self ):
self ._icon_anim_running =False
try :
if self ._icon_anim_job is not None :
try :
self .after_cancel (self ._icon_anim_job )
except Exception :
pass
self ._icon_anim_job =None
finally :
# restore static icon
self ._set_static_icon ()
def _run_with_icon_anim (self ,target ):
# run target in background while animating icon at ~30 fps
def runner ():
try :
# start on ui thread
self .after (0 ,self ._start_icon_animation )
self .after (0 ,lambda :self ._enter_busy ("Working…"))
target ()
finally :
# stop on ui thread
self .after (0 ,self ._leave_busy )
self .after (0 ,self ._stop_icon_animation )
threading .Thread (target =runner ,daemon =True ).start ()
def _add_history (self ,hist_list ,value ,maxlen =15 ):
v =(value or '').strip ()
if not v :
return
# deduplicate keep most recent at front
if v in hist_list :
hist_list .remove (v )
hist_list .insert (0 ,v )
# trim
del hist_list [maxlen :]
self ._refresh_combos ()
def _refresh_combos (self ):
# safely update all combobox values if they exist
try :
if hasattr (self ,'ipa_combo')and self .ipa_combo :
self .ipa_combo ['values']=self ._ipa_history
if hasattr (self ,'jf_ipa_combo')and self .jf_ipa_combo :
self .jf_ipa_combo ['values']=self ._ipa_history
except Exception :
pass
try :
if hasattr (self ,'user_combo')and self .user_combo :
self .user_combo ['values']=self ._user_history
if hasattr (self ,'jf_user_combo')and self .jf_user_combo :
self .jf_user_combo ['values']=self ._user_history
except Exception :
pass
try :
if hasattr (self ,'key_combo')and self .key_combo :
self .key_combo ['values']=self ._key_history
if hasattr (self ,'jf_key_combo')and self .jf_key_combo :
self .jf_key_combo ['values']=self ._key_history
except Exception :
pass
try :
if hasattr (self ,'ip_combo')and self .ip_combo :
self .ip_combo ['values']=self ._ip_history
if hasattr (self ,'jf_ip_combo')and self .jf_ip_combo :
self .jf_ip_combo ['values']=self ._ip_history
except Exception :
pass
try :
if hasattr (self ,'jf_app_combo')and self .jf_app_combo :
self .jf_app_combo ['values']=self ._appdir_history
except Exception :
pass
def _build_ui (self ):
# notebook tabs
notebook =ttk .Notebook (self )
notebook .pack (fill =tk .BOTH ,expand =True )
# installer tab
inst_tab =ttk .Frame (notebook )
notebook .add (inst_tab ,text ="Installer")
# two-pane layout so output is always visible without scroll
vpw =ttk .Panedwindow (inst_tab ,orient =tk .VERTICAL )
vpw .pack (fill =tk .BOTH ,expand =True )
top =ttk .Frame (vpw )
bottom =ttk .Frame (vpw )
# enforce minimum sizes so top never collapses to 0
try :
vpw .add (top ,minsize =320 )
vpw .add (bottom ,minsize =140 )
except Exception :
vpw .add (top )
vpw .add (bottom )
# initial sizes (after layout realized)
def _init_sash ():
try :
h =vpw .winfo_height ()
if h <=1 :
self .after (50 ,_init_sash )
return
vpw .sashpos (0 ,int (h *0.45 ))
except Exception :
pass
self .after (0 ,_init_sash )
# build main content in top pane
main =top
if isinstance (main ,ttk .Frame ):
try :
main .configure (padding =10 )
except Exception :
pass
# source ipa selection
src =ttk .LabelFrame (main ,text ="IPA selection")
src .pack (fill =tk .X ,padx =5 ,pady =5 )
self .ipa_combo =ttk .Combobox (src ,textvariable =self .ipa_path ,values =self ._ipa_history )
self .ipa_combo .pack (side =tk .LEFT ,fill =tk .X ,expand =True ,padx =5 ,pady =5 )
ttk .Button (src ,text ="Browse...",command =self ._choose_ipa ).pack (side =tk .LEFT ,padx =5 ,pady =5 )
# connection settings
conn =ttk .LabelFrame (main ,text ="Connection")
conn .pack (fill =tk .X ,padx =5 ,pady =5 )
row =ttk .Frame (conn )
row .pack (fill =tk .X )
ttk .Label (row ,text ="iPhone IP:").pack (side =tk .LEFT )
self .ip_combo =ttk .Combobox (row ,width =18 ,textvariable =self .iphone_ip ,values =self ._ip_history )
self .ip_combo .pack (side =tk .LEFT ,padx =5 )
ttk .Label (row ,text ="Port:").pack (side =tk .LEFT )
self .port_entry =ttk .Entry (row ,width =6 ,textvariable =self .iphone_port )
self .port_entry .pack (side =tk .LEFT ,padx =5 )
ttk .Label (row ,text ="User:").pack (side =tk .LEFT )
self .user_combo =ttk .Combobox (row ,width =12 ,textvariable =self .username ,values =self ._user_history )
self .user_combo .pack (side =tk .LEFT ,padx =5 )
row2 =ttk .Frame (conn )
row2 .pack (fill =tk .X ,pady =2 )
ttk .Label (row2 ,text ="Private Key:").pack (side =tk .LEFT )
self .key_combo =ttk .Combobox (row2 ,width =42 ,textvariable =self .private_key_path ,values =self ._key_history )
self .key_combo .pack (side =tk .LEFT ,padx =5 )
ttk .Button (row2 ,text ="Browse...",command =self ._choose_key ).pack (side =tk .LEFT )
row3 =ttk .Frame (conn )
row3 .pack (fill =tk .X ,pady =2 )
ttk .Label (row3 ,text ="Auth Type:").pack (side =tk .LEFT )
ttk .Combobox (row3 ,width =8 ,textvariable =self .auth_choice ,values =["RSA","DSS","Both"]).pack (side =tk .LEFT ,padx =5 )
ttk .Label (row3 ,text ="Auth:").pack (side =tk .LEFT )
ttk .Radiobutton (row3 ,text ="RSA",value ="RSA",variable =self .auth_choice ).pack (side =tk .LEFT )
ttk .Radiobutton (row3 ,text ="DSS",value ="DSS",variable =self .auth_choice ).pack (side =tk .LEFT )
ttk .Radiobutton (row3 ,text ="Both",value ="BOTH",variable =self .auth_choice ).pack (side =tk .LEFT )
ttk .Checkbutton (row3 ,text ="Also use password",variable =self .use_password ).pack (side =tk .LEFT ,padx =10 )
self .password_entry =ttk .Entry (row3 ,show ='*',width =18 ,textvariable =self .password )
self .password_entry .pack (side =tk .LEFT )
# test ssh button row
row4 =ttk .Frame (conn )
row4 .pack (fill =tk .X ,pady =2 )
ttk .Button (row4 ,text ="Test SSH",command =self ._on_test_ssh ).pack (side =tk .LEFT ,padx =5 ,pady =2 )
# profiles row
prof =ttk .Frame (conn )
prof .pack (fill =tk .X ,pady =2 )
ttk .Label (prof ,text ="Profile:").pack (side =tk .LEFT )
self .profile_combo =ttk .Combobox (prof ,width =20 ,textvariable =self .profile_name ,values =sorted (list (self .profiles .keys ())))
self .profile_combo .pack (side =tk .LEFT ,padx =5 )
ttk .Button (prof ,text ="Save",command =self ._profile_save ).pack (side =tk .LEFT ,padx =2 )
ttk .Button (prof ,text ="Load",command =self ._profile_load ).pack (side =tk .LEFT ,padx =2 )
ttk .Button (prof ,text ="Delete",command =self ._profile_delete ).pack (side =tk .LEFT ,padx =2 )
# installer choice
inst =ttk .LabelFrame (main ,text ="Installer")
inst .pack (fill =tk .X ,padx =5 ,pady =5 )
ttk .Radiobutton (inst ,text ="ipainstaller",value ="ipainstaller",variable =self .installer_choice ).pack (side =tk .LEFT ,padx =5 )
ttk .Radiobutton (inst ,text ="appinst",value ="appinst",variable =self .installer_choice ).pack (side =tk .LEFT ,padx =5 )
# ipainstaller options removed per request
# actions
actions =ttk .Frame (main )
actions .pack (fill =tk .X ,pady =6 )
self .install_btn =ttk .Button (actions ,text ="Install IPA",command =self ._on_install_click )
self .install_btn .pack (side =tk .LEFT )
self .run_ipainstaller_btn =ttk .Button (actions ,text ="Advanced: Run ipainstaller only",command =self ._on_run_ipainstaller_only )
self .run_ipainstaller_btn .pack (side =tk .LEFT ,padx =6 )
ttk .Checkbutton (actions ,text ="Raw ipainstaller output only",variable =self .raw_output ).pack (side =tk .LEFT ,padx =10 )
ttk .Checkbutton (actions ,text ="Show only commands",variable =self .commands_only ).pack (side =tk .LEFT )
# command preview
preview =ttk .LabelFrame (main ,text ="Command Preview")
preview .pack (fill =tk .X ,padx =5 ,pady =5 )
self .command_entry =ttk .Entry (preview ,textvariable =self .command_preview ,state ="readonly" )
self .command_entry .pack (side =tk .LEFT ,fill =tk .X ,expand =True ,padx =5 ,pady =5 )
ttk .Button (preview ,text ="Copy",command =lambda : (self .clipboard_clear (),self .clipboard_append (self .command_preview .get ())) ).pack (side =tk .LEFT ,padx =5 )
# status bar (bottom of Installer tab)
# separator above status to delineate footer
try :
ttk .Separator (inst_tab ,orient =tk .HORIZONTAL ).pack (fill =tk .X ,side =tk .BOTTOM )
except Exception :
pass
status =ttk .Frame (inst_tab )
status .pack (fill =tk .X ,side =tk .BOTTOM )
# small led indicator on the left
try :
self ._led_canvas =tk .Canvas (status ,width =12 ,height =12 ,highlightthickness =0 ,bd =0 )
self ._led_item =self ._led_canvas .create_oval (2 ,2 ,10 ,10 ,fill ="#9aa0a6" ,outline ="#777" )
self ._led_canvas .pack (side =tk .LEFT ,padx =6 ,pady =2 )
except Exception :
pass
ttk .Label (status ,textvariable =self .status_text ).pack (side =tk .LEFT ,padx =6 ,pady =2 )
ttk .Label (status ,textvariable =self .status_device ,foreground ="gray" ).pack (side =tk .RIGHT ,padx =6 ,pady =2 )
# tooltips basic
try :
self ._add_tooltip (self .command_entry ,"exact command that will run on device")
self ._add_tooltip (self .profile_combo ,"manage connection profiles")
# removed preset combo
self ._add_tooltip (self .ipa_combo ,"select or drop an ipa file")
self ._add_tooltip (self .ip_combo ,"device ip address")
self ._add_tooltip (self .user_combo ,"ssh username usually root")
self ._add_tooltip (self .key_combo ,"path to private key on this pc")
self ._add_tooltip (self .install_btn ,"install ipa with selected options")
self ._add_tooltip (self .run_ipainstaller_btn ,"run ipainstaller only with flags")
except Exception :
pass
# tools
tools =ttk .LabelFrame (main ,text ="Tools")
tools .pack (fill =tk .X ,padx =5 ,pady =5 )
ttk .Button (tools ,text ="Peek / (root)",command =self ._on_peek_root ).pack (side =tk .LEFT ,padx =4 ,pady =4 )
ttk .Button (tools ,text ="Respring (killall SpringBoard)",command =self ._on_respring ).pack (side =tk .LEFT ,padx =4 ,pady =4 )
ttk .Button (tools ,text ="Check AppSync status",command =self ._on_check_appsync ).pack (side =tk .LEFT ,padx =4 ,pady =4 )
ttk .Button (tools ,text ="Install AppSync 116.0",command =self ._on_install_appsync ).pack (side =tk .LEFT ,padx =4 ,pady =4 )
# output
out =ttk .LabelFrame (bottom ,text ="Output")
out .pack (fill =tk .BOTH ,expand =True ,padx =5 ,pady =5 )
self .output =ScrolledText (out ,height =16 ,wrap =tk .WORD ,state =tk .DISABLED )
# dark theme for output
try :
self .output .configure (background ="#0d1117" ,foreground ="#d1d5da" ,insertbackground ="#d1d5da" )
self .output .tag_configure ('dir',foreground ="#4ea1ff")
self .output .tag_configure ('app',foreground ="#00d2ff")
self .output .tag_configure ('exec',foreground ="#2bd46b")
self .output .tag_configure ('warn',foreground ="#ffd866")
self .output .tag_configure ('error',foreground ="#ff6b6b")
self .output .tag_configure ('path',foreground ="#c792ea")
except Exception :
pass
self .output .pack (fill =tk .BOTH ,expand =True )
# ixplorer tab
if ExplorerFrame is not None :
try :
explorer_tab =ExplorerFrame (
notebook ,
get_connection =self ._connect ,
ip_var =self .iphone_ip ,
)
notebook .add (explorer_tab ,text ="iXplorer")
except Exception as e :
# fallback: show tab with error message
err_tab =ttk .Frame (notebook )
ttk .Label (err_tab ,text =f"iXplorer failed to load: {e}").pack (padx =10 ,pady =10 )
notebook .add (err_tab ,text ="iXplorer")
else :
# if import failed still add a placeholder tab
placeholder =ttk .Frame (notebook )
ttk .Label (placeholder ,text ="iXplorer module not available.").pack (padx =10 ,pady =10 )
notebook .add (placeholder ,text ="iXplorer")
# applications tab lists /applications or /var/jb/applications with icons
try :
from applications_frame import ApplicationsFrame # local import to avoid hard dep if missing
apps_tab =ApplicationsFrame (
notebook ,
get_connection =self ._connect ,
)
notebook .add (apps_tab ,text ="Applications")
except Exception as e :
apps_err =ttk .Frame (notebook )
ttk .Label (apps_err ,text =f"Applications tab failed to load: {e}").pack (padx =10 ,pady =10 )
notebook .add (apps_err ,text ="Applications")
# jailfr3e-installipa tab
jf_tab =ttk .Frame (notebook )
notebook .add (jf_tab ,text ="JAILFR3E-INSTALLIPA")
jf_main =ttk .Frame (jf_tab )
jf_main .pack (fill =tk .BOTH ,expand =True ,padx =10 ,pady =10 )
# connection/auth reuse same vars
jf_conn =ttk .LabelFrame (jf_main ,text ="Connection & Auth (uses same settings)")
jf_conn .pack (fill =tk .X ,padx =5 ,pady =5 )
jf_row =ttk .Frame (jf_conn )
jf_row .pack (fill =tk .X )
ttk .Label (jf_row ,text ="iPhone IP:").pack (side =tk .LEFT )
self .jf_ip_combo =ttk .Combobox (jf_row ,width =18 ,textvariable =self .iphone_ip ,values =self ._ip_history )
self .jf_ip_combo .pack (side =tk .LEFT ,padx =5 )
ttk .Label (jf_row ,text ="Port:").pack (side =tk .LEFT )
ttk .Entry (jf_row ,width =6 ,textvariable =self .iphone_port ).pack (side =tk .LEFT ,padx =5 )
ttk .Label (jf_row ,text ="User:").pack (side =tk .LEFT )
self .jf_user_combo =ttk .Combobox (jf_row ,width =12 ,textvariable =self .username ,values =self ._user_history )
self .jf_user_combo .pack (side =tk .LEFT ,padx =5 )
ttk .Checkbutton (jf_row ,text ="Also use password",variable =self .use_password ).pack (side =tk .LEFT ,padx =10 )
ttk .Entry (jf_row ,show ='*',width =18 ,textvariable =self .password ).pack (side =tk .LEFT )
jf_row2 =ttk .Frame (jf_conn )
jf_row2 .pack (fill =tk .X ,pady =2 )
ttk .Label (jf_row2 ,text ="Private Key:").pack (side =tk .LEFT )
self .jf_key_combo =ttk .Combobox (jf_row2 ,width =42 ,textvariable =self .private_key_path ,values =self ._key_history )
self .jf_key_combo .pack (side =tk .LEFT ,padx =5 )
ttk .Button (jf_row2 ,text ="Browse...",command =self ._choose_key ).pack (side =tk .LEFT )
jf_row3 =ttk .Frame (jf_conn )
jf_row3 .pack (fill =tk .X ,pady =2 )
ttk .Label (jf_row3 ,text ="Auth Type:").pack (side =tk .LEFT )
ttk .Combobox (jf_row3 ,width =8 ,textvariable =self .auth_choice ,values =["RSA","DSS","Both"]).pack (side =tk .LEFT ,padx =5 )
jf_src =ttk .LabelFrame (jf_main ,text ="IPA selection")
jf_src .pack (fill =tk .X ,padx =5 ,pady =5 )
self .jf_ipa_combo =ttk .Combobox (jf_src ,textvariable =self .ipa_path ,values =self ._ipa_history )
self .jf_ipa_combo .pack (side =tk .LEFT ,fill =tk .X ,expand =True ,padx =5 ,pady =5 )
ttk .Button (jf_src ,text ="Browse...",command =self ._choose_ipa ).pack (side =tk .LEFT ,padx =5 ,pady =5 )
jf_app =ttk .LabelFrame (jf_main ,text ="AppDrop: .app folder (optional if IPA provided)")
jf_app .pack (fill =tk .X ,padx =5 ,pady =5 )
self .jf_app_combo =ttk .Combobox (jf_app ,textvariable =self .app_dir_path ,values =self ._appdir_history )
self .jf_app_combo .pack (side =tk .LEFT ,fill =tk .X ,expand =True ,padx =5 ,pady =5 )
ttk .Button (jf_app ,text ="Browse...",command =self ._choose_app_dir ).pack (side =tk .LEFT ,padx =5 ,pady =5 )
# jf command preview
jf_prev =ttk .LabelFrame (jf_main ,text ="Command Preview")
jf_prev .pack (fill =tk .X ,padx =5 ,pady =5 )