-
Notifications
You must be signed in to change notification settings - Fork 11
/
admin.cpp
2878 lines (2210 loc) · 79 KB
/
admin.cpp
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
// ライセンス: GPL2
//#define _DEBUG
#include "jddebug.h"
#include "admin.h"
#include "window.h"
#include "view.h"
#include "dragnote.h"
#include "msgdiag.h"
#include "tabswitchmenu.h"
#include "dbtree/interface.h"
#include "jdlib/miscutil.h"
#include "jdlib/miscgtk.h"
#include "history/historymanager.h"
#include "history/viewhistoryitem.h"
#include "control/controlutil.h"
#include "control/controlid.h"
#include "config/globalconf.h"
#include "command.h"
#include "session.h"
#include "global.h"
#include "updatemanager.h"
#include <algorithm>
enum
{
MAX_TABS = 50
};
// open_view で使うモード
enum
{
OPEN_MODE_AUTO = 1,
OPEN_MODE_NOSWITCH = 2,
OPEN_MODE_LOCK = 4,
OPEN_MODE_OFFLINE = 8,
OPEN_MODE_REGET = 16
};
using namespace SKELETON;
Admin::Admin( const std::string& url )
: m_url( url ),
m_win( NULL ),
m_notebook( NULL ),
m_focus( false ),
m_move_menu( NULL ),
m_tabswitchmenu( NULL ),
m_use_viewhistory( false ),
m_use_switchhistory( false )
{
m_notebook = new DragableNoteBook();
m_notebook->signal_switch_page().connect( sigc::mem_fun( *this, &Admin::slot_switch_page ) );
m_notebook->set_scrollable( true );
m_notebook->sig_tab_clicked().connect( sigc::mem_fun( *this, &Admin::slot_tab_clicked ) );
m_notebook->sig_tab_scrolled().connect( sigc::mem_fun( *this, &Admin::slot_tab_scrolled ) );
m_notebook->sig_tab_close().connect( sigc::mem_fun( *this, &Admin::slot_tab_close ) );
m_notebook->sig_tab_reload().connect( sigc::mem_fun( *this, &Admin::slot_tab_reload ) );
m_notebook->sig_tab_menu().connect( sigc::mem_fun( *this, &Admin::slot_tab_menu ) );
m_notebook->get_tabswitch_button().signal_clicked().connect( sigc::mem_fun(*this, &Admin::slot_show_tabswitchmenu ) );
// D&D
m_notebook->sig_drag_data_get().connect( sigc::mem_fun(*this, &Admin::slot_drag_data_get ) );
m_list_command.clear();
}
Admin::~Admin()
{
#ifdef _DEBUG
std::cout << "Admin::~Admin " << m_url << std::endl;
#endif
// デストラクタの中からdispatchを呼ぶと落ちるので dispatch不可にする
set_dispatchable( false );
const int pages = m_notebook->get_n_pages();
#ifdef _DEBUG
std::cout << "pages = " << pages << std::endl;
#endif
if( pages ){
for( int i = 0; i < pages; ++i ){
SKELETON::View* view = dynamic_cast< View* >( m_notebook->get_nth_page( 0 ) );
m_notebook->remove_page( 0, false );
if( view ) delete view;
}
}
m_list_command.clear();
close_window();
delete_jdwin();
if( m_notebook ) delete m_notebook;
if( m_move_menu ) delete m_move_menu;
if( m_tabswitchmenu ) delete m_tabswitchmenu;
}
void Admin::save_session()
{
std::list< SKELETON::View* > list_view = get_list_view();
std::list< SKELETON::View* >::iterator it = list_view.begin();
for( ; it != list_view.end(); ++it ){
SKELETON::View* view = ( *it );
if( view ) view->save_session();
}
}
//
// メニューのセットアップ
//
void Admin::setup_menu()
{
// 右クリックメニュー
m_action_group = Gtk::ActionGroup::create();
m_action_group->add( Gtk::Action::create( "Quit", "Quit" ), sigc::mem_fun( *this, &Admin::slot_close_tab ) );
m_action_group->add( Gtk::ToggleAction::create( "LockTab", "タブをロックする(_K)", std::string(), false ),
sigc::mem_fun( *this, &Admin::slot_lock ) );
m_action_group->add( Gtk::Action::create( "Close_Tab_Menu", "複数のタブを閉じる(_T)" ) );
m_action_group->add( Gtk::Action::create( "CloseOther", "他のタブ(_O)" ), sigc::mem_fun( *this, &Admin::slot_close_other_tabs ) );
m_action_group->add( Gtk::Action::create( "CloseLeft", "左←のタブ(_L)" ), sigc::mem_fun( *this, &Admin::slot_close_left_tabs ) );
m_action_group->add( Gtk::Action::create( "CloseRight", "右→のタブ(_R)" ), sigc::mem_fun( *this, &Admin::slot_close_right_tabs ) );
m_action_group->add( Gtk::Action::create( "CloseAll", "全てのタブ(_A)" ), sigc::mem_fun( *this, &Admin::slot_close_all_tabs ) );
m_action_group->add( Gtk::Action::create( "CloseSameIcon", "同じアイコンのタブ(_I)" ), sigc::mem_fun( *this, &Admin::slot_close_same_icon_tabs ) );
m_action_group->add( Gtk::Action::create( "Reload_Tab_Menu", "全てのタブの再読み込み(_A)" ) );
m_action_group->add( Gtk::Action::create( "CheckUpdateAll", "更新チェックのみ(_U)" ), sigc::mem_fun( *this, &Admin::slot_check_update_all_tabs ) );
m_action_group->add( Gtk::Action::create( "CheckUpdateReloadAll", "更新されたタブを再読み込み(_A)" ),
sigc::mem_fun( *this, &Admin::slot_check_update_reload_all_tabs ) );
m_action_group->add( Gtk::Action::create( "ReloadAll", "再読み込み(_R)" ), sigc::mem_fun( *this, &Admin::slot_reload_all_tabs ) );
m_action_group->add( Gtk::Action::create( "CancelReloadAll", "キャンセル(_C)" ), sigc::mem_fun( *this, &Admin::slot_cancel_reload_all_tabs ) );
m_action_group->add( Gtk::Action::create( "OpenBrowser", ITEM_NAME_OPEN_BROWSER "(_W)" ),
sigc::mem_fun( *this, &Admin::slot_open_by_browser ) );
m_action_group->add( Gtk::Action::create( "CopyURL", ITEM_NAME_COPY_URL "(_U)" ), sigc::mem_fun( *this, &Admin::slot_copy_url ) );
m_action_group->add( Gtk::Action::create( "CopyTitleURL", ITEM_NAME_COPY_TITLE_URL "(_L)" ),
sigc::mem_fun( *this, &Admin::slot_copy_title_url ) );
m_action_group->add( Gtk::Action::create( "Preference", "プロパティ(_P)..."), sigc::mem_fun( *this, &Admin::show_preference ) );
// 戻る、進む
m_action_group->add( Gtk::Action::create( "PrevView", "PrevView"),
sigc::bind< int >( sigc::mem_fun( *this, &Admin::back_clicked_viewhistory ), 1 ) );
m_action_group->add( Gtk::Action::create( "NextView", "NextView"),
sigc::bind< int >( sigc::mem_fun( *this, &Admin::forward_clicked_viewhistory ), 1 ) );
m_ui_manager = Gtk::UIManager::create();
m_ui_manager->insert_action_group( m_action_group );
// ポップアップメニューのレイアウト
Glib::ustring str_ui =
"<ui>"
// 通常
"<popup name='popup_menu'>"
"<menuitem action='LockTab'/>"
"<separator/>"
"<menuitem action='Quit'/>"
"<separator/>"
"<menu action='Close_Tab_Menu'>"
"<menuitem action='CloseAll'/>"
"<menuitem action='CloseOther'/>"
"<menuitem action='CloseLeft'/>"
"<menuitem action='CloseRight'/>"
"<menuitem action='CloseSameIcon'/>"
"</menu>"
"<separator/>"
"<menu action='Reload_Tab_Menu'>"
"<menuitem action='ReloadAll'/>"
"<menuitem action='CheckUpdateAll'/>"
"<menuitem action='CheckUpdateReloadAll'/>"
"<separator/>"
"<menuitem action='CancelReloadAll'/>"
"</menu>"
"<separator/>"
"<menuitem action='OpenBrowser'/>"
"<separator/>"
"<menuitem action='CopyURL'/>"
"<menuitem action='CopyTitleURL'/>"
"<separator/>"
"<menuitem action='Preference'/>"
"</popup>"
"</ui>";
m_ui_manager->add_ui_from_string( str_ui );
Gtk::Menu* popupmenu = dynamic_cast< Gtk::Menu* >( m_ui_manager->get_widget( "/popup_menu" ) );
Gtk::MenuItem* item;
// 移動サブメニュー
m_move_menu = new SKELETON::TabSwitchMenu( m_notebook, this );
// 進む、戻る
Glib::RefPtr< Gtk::Action > act;
act = m_action_group->get_action( "PrevView" );
act->set_accel_group( m_ui_manager->get_accel_group() );
item = Gtk::manage( act->create_menu_item() );
m_move_menu->append( *item );
act = m_action_group->get_action( "NextView" );
act->set_accel_group( m_ui_manager->get_accel_group() );
item = Gtk::manage( act->create_menu_item() );
m_move_menu->append( *item );
m_move_menu->append( *Gtk::manage( new Gtk::SeparatorMenuItem() ) );
// 先頭、最後に移動
item = Gtk::manage( new Gtk::MenuItem( "先頭のタブに移動(_H)", true ) );
m_move_menu->append( *item );
item->signal_activate().connect( sigc::mem_fun( *this, &Admin::tab_head_focus ) );
item = Gtk::manage( new Gtk::MenuItem( "最後のタブに移動(_T)", true ) );
m_move_menu->append( *item );
item->signal_activate().connect( sigc::mem_fun( *this, &Admin::tab_tail_focus ) );
m_move_menu->append( *Gtk::manage( new Gtk::SeparatorMenuItem() ) );
m_move_menuitem = Gtk::manage( new Gtk::MenuItem( "移動" ) );
m_move_menuitem->set_submenu( *m_move_menu );
popupmenu->insert( *m_move_menuitem, 0 );
m_move_menuitem->show_all();
item = Gtk::manage( new Gtk::SeparatorMenuItem() );
popupmenu->insert( *item, 1 );
item->show_all();
// ポップアップメニューにアクセレータを表示
CONTROL::set_menu_motion( popupmenu );
popupmenu->signal_deactivate().connect( sigc::mem_fun( *this, &Admin::slot_popupmenu_deactivate ) );
}
void Admin::slot_popupmenu_deactivate()
{
if( m_move_menu ) m_move_menu->deactivate();
}
Gtk::Widget* Admin::get_widget()
{
return dynamic_cast< Gtk::Widget*>( m_notebook );
}
Gtk::Window* Admin::get_win()
{
return dynamic_cast< Gtk::Window*>( m_win );
}
void Admin::delete_jdwin()
{
if( m_win ){
delete m_win;
m_win = NULL;
}
}
bool Admin::is_booting()
{
if( get_jdwin() && get_jdwin()->is_booting() ) return true;
return ( has_commands() );
}
//
// ページが含まれていないか
//
bool Admin::empty()
{
return ( m_notebook->get_n_pages() == 0 );
}
// タブの数
int Admin::get_tab_nums()
{
if( m_notebook ) return m_notebook->get_n_pages();
return 0;
}
//
// 含まれているページのURLのリスト取得
//
std::list<std::string> Admin::get_URLs()
{
std::list<std::string> urls;
const int pages = m_notebook->get_n_pages();
if( pages ){
for( int i = 0; i < pages; ++i ){
SKELETON::View* view = dynamic_cast< SKELETON::View* >( m_notebook->get_nth_page( i ) );
if( view ) urls.push_back( view->get_url() );
}
}
return urls;
}
//
// クロック入力
//
void Admin::clock_in()
{
// アクティブなビューにクロックを送る
SKELETON::View* view = get_current_view();
if( view ) view->clock_in();
// 全てのビューにクロックを送る
// clock_in_always()には軽い処理だけを含めること
const int pages = m_notebook->get_n_pages();
if( pages ){
for( int i = 0; i < pages; ++i ){
SKELETON::View* view = dynamic_cast< SKELETON::View* >( m_notebook->get_nth_page( i ) );
if( view ) view->clock_in_always();
}
}
m_notebook->clock_in();
if( m_win ) m_win->clock_in();
}
//
// コマンド受付(通常)
//
void Admin::set_command( const std::string& command, const std::string& url,
const std::string& arg1, const std::string& arg2,
const std::string& arg3, const std::string& arg4,
const std::string& arg5, const std::string& arg6,
const std::string& arg7, const std::string& arg8 )
{
COMMAND_ARGS command_arg;
command_arg.command = command;
command_arg.url = url;
command_arg.arg1 = arg1;
command_arg.arg2 = arg2;
command_arg.arg3 = arg3;
command_arg.arg4 = arg4;
command_arg.arg5 = arg5;
command_arg.arg6 = arg6;
command_arg.arg7 = arg7;
command_arg.arg8 = arg8;
set_command_impl( false, command_arg );
}
//
// コマンド受付(即実行)
//
void Admin::set_command_immediately( const std::string& command, const std::string& url,
const std::string& arg1, const std::string& arg2,
const std::string& arg3, const std::string& arg4,
const std::string& arg5, const std::string& arg6,
const std::string& arg7, const std::string& arg8 )
{
COMMAND_ARGS command_arg;
command_arg.command = command;
command_arg.url = url;
command_arg.arg1 = arg1;
command_arg.arg2 = arg2;
command_arg.arg3 = arg3;
command_arg.arg4 = arg4;
command_arg.arg5 = arg5;
command_arg.arg6 = arg6;
command_arg.arg7 = arg7;
command_arg.arg8 = arg8;
set_command_impl( true, command_arg );
}
//
// コマンド受付
//
// immediately = false の場合はすぐにコマンドを実行しないで一旦Dispatcherで
// メインスレッドにコマンドを渡してからメインスレッドで実行する。通常は
// immediately = false で呼び出して、緊急にコマンドを実行させたい場合は
// immediately = true とすること。
//
void Admin::set_command_impl( const bool immediately, const COMMAND_ARGS& command_arg )
{
#ifdef _DEBUG
std::cout << "Admin::set_command : immediately = " << immediately
<< " command = " << command_arg.command
<< " url = " << command_arg.url << std::endl
<< command_arg.arg1 << " " << command_arg.arg2 << std::endl
<< command_arg.arg3 << " " << command_arg.arg4 << std::endl
<< command_arg.arg5 << " " << command_arg.arg6 << std::endl
<< command_arg.arg7 << " " << command_arg.arg8 << std::endl;
#endif
if( immediately ){
m_list_command.push_front( command_arg );
exec_command();
}
else{
m_list_command.push_back( command_arg );
dispatch(); // 一度メインループに戻った後にcallback_dispatch() が呼び戻される
}
}
//
// ディスパッチャのコールバック関数
//
void Admin::callback_dispatch()
{
while( m_list_command.size() ) exec_command();
}
//
// コマンド実行
//
void Admin::exec_command()
{
if( m_list_command.size() == 0 ) return;
COMMAND_ARGS command = m_list_command.front();
m_list_command.pop_front();
// コマンドリストが空になったことをcoreに知らせる
if( m_list_command.size() == 0 ) CORE::core_set_command( "empty_command", m_url );
#ifdef _DEBUG
std::cout << "Admin::exec_command " << m_url << " : " << command.command << " " << command.url << " " << std::endl
<< command.arg1 << " " << command.arg2 << std::endl
<< command.arg3 << " " << command.arg4 << std::endl
<< command.arg5 << " " << command.arg6 << std::endl;
#endif
// 前回終了時の状態を回復
if( command.command == "restore" ){
restore( ( command.arg1 == "only_locked" ) );
}
// 移転などでホストの更新
else if( command.command == "update_url" ){
update_url( command.url, command.arg1 );
}
// 板名更新
else if( command.command == "update_boardname" ){
update_boardname( command.url );
}
// viewを開く
else if( command.command == "open_view" ){
open_view( command );
}
// リストで開く
// arg1 にはdatファイルを空白で区切って指定する
//
else if( command.command == "open_list" ){
open_list( command );
}
else if( command.command == "switch_view" ){
switch_view( command.url );
}
else if( command.command == "reload_view" ){
reload_view( command.url );
}
else if( command.command == "tab_left" ){
tab_left( false );
}
else if( command.command == "tab_right" ){
tab_right( false );
}
else if( command.command == "tab_left_updated" ){
tab_left( true );
}
else if( command.command == "tab_right_updated" ){
tab_right( true );
}
else if( command.command == "tab_num" ){
tab_num( command.arg1 );
}
else if( command.command == "tab_head" ){
tab_head();
}
else if( command.command == "tab_tail" ){
tab_tail();
}
else if( command.command == "set_tab_operating" ){
#ifdef _DEBUG
std::cout << command.command << " " << m_url << " " << command.arg1 << std::endl;
#endif
if( command.arg1 == "true" ) SESSION::set_tab_operating( m_url, true );
else{
SESSION::set_tab_operating( m_url, false );
if( ! empty() ){
// 現在開いているタブへの switch 処理
const bool focus_tmp = m_focus;
m_focus = true;
slot_switch_page( NULL, m_notebook->get_current_page() );
m_focus = focus_tmp;
}
}
}
else if( command.command == "redraw" ){
redraw_view( command.url );
}
else if( command.command == "redraw_current_view" ){
redraw_current_view();
}
else if( command.command == "relayout_current_view" ){
relayout_current_view();
}
// command.url を含むview全てを検索して表示中なら再描画
else if( command.command == "redraw_views" ){
redraw_views( command.url );
}
else if( command.command == "update_view" ){ // ビュー全体を更新
update_view( command.url );
}
else if( command.command == "update_item" ){ // ビューの一部を更新
update_item( command.url, command.arg1 );
}
else if( command.command == "update_finish" ){
update_finish( command.url );
}
// 全ロック解除
else if( command.command == "unlock_views" ){
unlock_all_view( command.url );
}
// ビューを閉じる
else if( command.command == "close_view" ){
if( command.arg1 == "closeall" ) close_all_view( command.url ); // command.url を含むタブを全て閉じる
else if( command.arg1 == "closealltabs" ) slot_close_all_tabs(); // 全て閉じる
else if( command.arg1 == "closeother" ) close_other_views( command.url );
else close_view( command.url );
}
else if( command.command == "close_currentview" ){
close_current_view();
}
// 最後に閉じたタブを復元する
else if( command.command == "restore_lasttab" ){
restore_lasttab();
}
else if( command.command == "set_page" ){
set_current_page( atoi( command.arg1.c_str() ) );
}
// フォーカスイン、アウト
else if( command.command == "focus_current_view" ){
m_focus = true;
focus_current_view();
}
else if( command.command == "focus_out" ){
m_focus = false;
focus_out();
}
else if( command.command == "restore_focus" ){
m_focus = true;
restore_focus();
}
// adminクラスを前面に出す
else if( command.command == "switch_admin" ){
switch_admin();
}
// タブに文字をセット、タブ幅調整
else if( command.command == "set_tablabel" ){
set_tablabel( command.url, command.arg1 );
}
else if( command.command == "adjust_tabwidth" ){
m_notebook->adjust_tabwidth();
}
// 全てのビューを再描画
else if( command.command == "relayout_all" ) relayout_all();
// タイトル表示
// アクティブなviewから依頼が来たらコアに渡す
else if( command.command == "set_title" ){
const bool force = ( command.arg2 == "force" );
set_title( command.url, command.arg1, force );
}
// ステータス表示
// アクティブなviewから依頼が来たらコアに渡す
else if( command.command == "set_status" ){
const bool force = ( command.arg2 == "force" );
set_status( command.url, command.arg1, force );
}
// ステータスの色を変える
else if( command.command == "set_status_color" ){
const bool force = ( command.arg2 == "force" );
set_status_color( command.url, command.arg1, force );
}
// マウスジェスチャ
else if( command.command == "set_mginfo" ){
if( m_win ) m_win->set_mginfo( command.arg1 );
}
// 全タブオートリロード
else if( command.command == "reload_all_tabs" ){
reload_all_tabs();
}
// 全タブ更新チェックして開く
else if( command.command == "check_update_reload_all_tabs" ){
check_update_all_tabs( true );
}
// オートリロードのキャンセル
else if( command.command == "cancel_reload" ){
slot_cancel_reload_all_tabs();
}
// タブを隠す
else if( command.command == "hide_tabs" ) m_notebook->set_show_tabs( false );
// window 開け閉じ
else if( command.command == "open_window" ){
open_window();
return;
}
else if( command.command == "close_window" ){
close_window();
return;
}
// ツールバーの検索ボックスをフォーカス
else if( command.command == "focus_toolbar_search" ){
focus_toolbar_search();
}
// ツールバー表示/非表示切り替え
else if( command.command == "toggle_toolbar" ){
toggle_toolbar();
}
// ツールバーのアドレスを更新
else if( command.command == "update_toolbar_url" ){
m_notebook->update_toolbar_url( command.url, command.arg1 );
}
// ツールバーのラベルを更新
else if( command.command == "redraw_toolbar" ){
redraw_toolbar();
}
// ツールバーボタン表示更新
else if( command.command == "update_toolbar_button" ){
update_toolbar_button();
}
// 検索バー表示
else if( command.command == "open_searchbar" ){
open_searchbar();
}
// 検索バー非表示
else if( command.command == "close_searchbar" ){
close_searchbar();
}
// タブ表示切り替え
else if( command.command == "toggle_tab" ){
toggle_tab();
}
// アイコン表示切り替え
else if( command.command == "toggle_icon" ){
toggle_icon( command.url );
}
// window 開け閉じ可能/不可
else if( command.command == "enable_fold_win" ){
if( get_jdwin() ) get_jdwin()->set_enable_fold( true );
}
else if( command.command == "disable_fold_win" ){
if( get_jdwin() ) get_jdwin()->set_enable_fold( false );
}
// プロパティ表示
else if( command.command == "show_preferences" ){
SKELETON::View* view = get_view( command.url );
if( view ) view->show_preference();
}
else if( command.command == "show_current_preferences" ){
SKELETON::View* view = get_current_view();
if( view ) view->show_preference();
}
// View履歴:戻る
else if( command.command == "back_viewhistory" ){
back_viewhistory( command.url, atoi( command.arg1.c_str() ) );
}
// View履歴:進む
else if( command.command == "forward_viewhistory" ){
forward_viewhistory( command.url, atoi( command.arg1.c_str() ) );
}
// View履歴削除
else if( command.command == "clear_viewhistory" ){
clear_viewhistory();
}
// オートリロード開始
else if( command.command == "start_autoreload" ){
int mode = AUTORELOAD_ON;
if( command.arg1 == "once" ) mode = AUTORELOAD_ONCE;
int sec = atoi( command.arg2.c_str() );
set_autoreload_mode( command.url, mode, sec );
}
// オートリロード停止
else if( command.command == "stop_autoreload" ){
set_autoreload_mode( command.url, AUTORELOAD_NOT, 0 );
}
// ポップアップを隠す(インスタンスは削除しない)
else if( command.command == "hide_popup" ) hide_popup();
else{
// ツールバー関係
SKELETON::View* view = get_view( command.url );
if( view && command.command == "toolbar_exec_search" ) view->exec_search();
else if( view && command.command == "toolbar_operate_search" ) view->operate_search( command.arg1 );
else if( view && command.command == "toolbar_set_search_query" ) view->set_search_query( command.arg1 );
if( view && command.command == "toolbar_up_search" ) view->up_search();
if( view && command.command == "toolbar_down_search" ) view->down_search();
else if( view && command.command == "toolbar_write" ) view->write();
else if( view && command.command == "toolbar_reload" ) view->reload();
else if( view && command.command == "toolbar_stop" ) view->stop();
else if( view && command.command == "toolbar_close_view" ) view->close_view();
else if( view && command.command == "toolbar_delete_view" ) view->delete_view();
else if( view && command.command == "toolbar_set_favorite" ) view->set_favorite();
// ロック/アンロック
else if( view && command.command == "toolbar_lock_view" ){
if( view->is_locked() ) unlock( get_current_page() );
else lock( get_current_page() );
}
// 子クラス別のコマンド処理
else command_local( command );
}
}
// リストで与えられたページをタブで連続して開く
//
// 連続してリロードかけるとサーバに負担をかけるので、オフラインで開いて
// タイミングをずらしながらリロードする
//
void Admin::open_list( const COMMAND_ARGS& command_list )
{
#ifdef _DEBUG
std::cout << "Admin::open_list " << m_url << std::endl;
#endif
const std::string& str_list = command_list.arg1;
std::list< std::string > list_url = MISC::split_line( str_list );
if( list_url.empty() ) return;
int waittime = 0;
const bool online = SESSION::is_online();
SESSION::set_tab_operating( m_url, true );
std::list< std::string >::iterator it = list_url.begin();
for( ; it != list_url.end(); ++it, waittime += AUTORELOAD_MINSEC ){
// 各admin別の引数をセット
COMMAND_ARGS command_arg = get_open_list_args( ( *it ), command_list );
// 共通の引数をセット
command_arg.command = "open_view";
command_arg.url = (*it);
command_arg.arg1 = "true"; // タブで開く
command_arg.arg2 = "false"; // 既に開いているかチェック
command_arg.arg3 = "noswitch"; // タブを切り替えない
if( ! command_list.arg2.empty() ) command_arg.arg3 += " " + command_list.arg2;
#ifdef _DEBUG
std::cout << "url = " << command_arg.url << std::endl;
#endif
open_view( command_arg );
// 一番最初のページは普通にオンラインで開く
// 二番目からは ウェイトを入れてリロード
if( online ){
if( !waittime ) SESSION::set_online( false );
else set_autoreload_mode( command_arg.url, AUTORELOAD_ONCE, waittime );
}
}
SESSION::set_online( online );
set_command( "set_tab_operating", "", "false" );
switch_admin();
switch_view( *( list_url.begin() ) );
}
//
// 移転などでviewのurlを更新
//
void Admin::update_url( const std::string& url_old, const std::string& url_new )
{
#ifdef _DEBUG
std::cout << "Admin::update_url " << url_old << " -> " << url_new << std::endl;
#endif
const int pages = m_notebook->get_n_pages();
if( pages ){
for( int i = 0; i < pages; ++i ){
SKELETON::View* view = dynamic_cast< View* >( m_notebook->get_nth_page( i ) );
if( view && view->get_url().find( url_old ) == 0 ){
std::list< std::string >::iterator it
= std::find( m_list_switchhistory.begin(), m_list_switchhistory.end(), view->get_url() );
view->update_url( url_old, url_new );
if( it != m_list_switchhistory.end() ) (*it) = view->get_url();
}
}
}
}
//
// urlを含むviewの板名を更新
//
void Admin::update_boardname( const std::string& url )
{
#ifdef _DEBUG
std::cout << "Admin::update_boardname url = " << url << std::endl;
#endif
const int pages = m_notebook->get_n_pages();
if( pages ){
for( int i = 0; i < pages; ++i ){
SKELETON::View* view = dynamic_cast< View* >( m_notebook->get_nth_page( i ) );
if( view && view->get_url().find( url ) == 0 ) view->update_boardname();
}
redraw_toolbar();
}
}
//
// URLやステータスを更新
//
void Admin::update_status( View* view, const bool force )
{
if( view ){
set_title( view->get_url(), view->get_title(), force );
set_url( view->get_url(), view->url_for_copy(), force );
set_status( view->get_url(), view->get_status(), force );
set_status_color( view->get_url(), view->get_color(), force );
}
}
//
// ビューを開く
//
// command.arg1: 開く位置
//
// "false" ならアクティブなタブを置き換える ( デフォルト )
// "true" なら一番右側に新しいタブを開く
// "right" ならアクティブなタブの右に開く
// "newtab" "opentab" なら設定によってアクティブなタブの右に開くか一番右側に開くか切り替える
// "left" ならアクティブなタブの左に開く
// "page数字" なら指定した位置にタブで開く
// "replace" なら arg3 に指定したタブがあれば置き換え、なければ "newtab" で動作する
//
// command.arg2: "true" なら既に command.url を開いているかチェックしない
//
// command.arg3: モード ( 複数指定する場合は空白で空ける )
//
// "auto"なら表示されていればリロードせずに切替える
// されていなければarg1で指定した場所に新しいタブで開いてロード
// スレ番号ジャンプなどで使用する
// "noswitch"ならタブを切り替えない(連続して開くときに使用)
// "lock" なら開いてからロックする
// "offline" なら オフラインで開く
// "reget" なら読み込み時にキャッシュ等を消してから再読み込みする
// "boardnext" など、 "replace" で置き換えるタブの種類を指定する
//
// その他のargは各ビュー別の設定
//
void Admin::open_view( const COMMAND_ARGS& command )
{
#ifdef _DEBUG
std::cout << "Admin::open_view : " << command.url << std::endl
<< "arg1 = " << command.arg1 << std::endl
<< "arg2 = " << command.arg2 << std::endl
<< "arg3 = " << command.arg3 << std::endl;
#endif
SKELETON::View* view;
SKELETON::View* current_view = get_current_view();
const bool online = SESSION::is_online();
const bool nocheck_opened = ( command.arg2 == "true" );
int mode = 0;
if( ! command.arg3.empty() ){
if( command.arg3.find( "auto" ) != std::string::npos ) mode |= OPEN_MODE_AUTO;
if( command.arg3.find( "noswitch" ) != std::string::npos ) mode |= OPEN_MODE_NOSWITCH;
if( command.arg3.find( "lock" ) != std::string::npos ) mode |= OPEN_MODE_LOCK;
if( command.arg3.find( "offline" ) != std::string::npos ) mode |= OPEN_MODE_OFFLINE;
if( command.arg3.find( "reget" ) != std::string::npos ) mode |= OPEN_MODE_REGET;
}
if( current_view ) current_view->focus_out();
// urlを既に開いていたら表示してリロード
if( ! nocheck_opened ){
view = get_view( command_to_url( command ) );
if( view ){