-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileClient.pm
executable file
·175 lines (134 loc) · 4.03 KB
/
fileClient.pm
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
#!/usr/bin/perl
#-------------------------------------------------------------------------
# the main application object
#-------------------------------------------------------------------------
# Currently uses 'buddy' standard data dir to hold the fileClient.prefs file
# PRH - need to implement prefsDlg
# PRH - I think buddy prefs go in fileClient.prefs (it's all one big thing?)
package apps::fileClient::AppFrame;
use strict;
use warnings;
use threads;
use threads::shared;
use Wx qw(:everything);
use Wx::Event qw(EVT_MENU_RANGE);
use Pub::Utils;
use Pub::WX::Frame;
use apps::fileClient::Resources;
use apps::fileClient::Window;
use apps::fileClient::fcPrefs;
use apps::fileClient::PrefsDialog;
use apps::fileClient::ConnectDialog;
use base qw(Pub::WX::Frame);
my $dbg_app = 0;
sub new
{
my ($class, $parent) = @_;
warning($dbg_app,-1,"FILE CLIENT STARTED WITH PID($$)");
return if !initFCPrefs();
# we get the prefs first cuz there are preferences
# related to how we want to restore the app
# if any command line arguments are passed,
# or the restore_startup pref is not set,
# we merely restore the main window rectangle.
#
# otherwise, the Frame base class witll restore
# the windows, and later we will NOT do the
# auto-start connections loop
my $how_restore = !@ARGV && getFCPref('restore_startup') ?
$RESTORE_ALL : $RESTORE_MAIN_RECT;
Pub::WX::Frame::setHowRestore($how_restore);
# apps decide how they want to restore from ini file
my $this = $class->SUPER::new($parent);
# Create the super class, which does the restoreState()
# start connection from cmmand line if @ARG, or
# any auto_start connections if not ..
if (@ARGV)
{
my $connection = parseCommandLine();
return if !$connection;
$this->createPane($ID_CLIENT_WINDOW,undef,$connection)
}
elsif (!getFCPref('restore_startup'))
{
my @start_connections;
return if !waitFCPrefs();
for my $shared_connection (@{getFCPrefs()->{connections}})
{
push @start_connections,getPrefConnection(
$shared_connection->{connection_id})
if $shared_connection->{auto_start};
}
releaseFCPrefs();
for my $connection (@start_connections)
{
$this->createPane($ID_CLIENT_WINDOW,undef,$connection);
}
}
# register event handlers and we're done
EVT_MENU_RANGE($this, $COMMAND_PREFS, $COMMAND_CONNECT, \&onCommand);
return $this;
}
sub createPane
{
my ($this,$id,$book,$data) = @_;
display($dbg_app,0,"fileClient::createPane($id)".
" book="._def($book).
" data="._def($data) );
if ($id == $ID_CLIENT_WINDOW)
{
$book ||= $this->{book};
return apps::fileClient::Window->new($this,$id,$book,$data);
}
return $this->SUPER::createPane($id,$book,$data);
}
sub onCommand
{
my ($this,$event) = @_;
my $id = $event->GetId();
apps::fileClient::ConnectDialog->connect() if $id == $COMMAND_CONNECT;
apps::fileClient::PrefsDialog->editPrefs() if $id == $COMMAND_PREFS;
}
#----------------------------------------------------
# CREATE AND RUN THE APPLICATION
#----------------------------------------------------
package apps::fileClient::App;
use strict;
use warnings;
use threads;
use threads::shared;
use Pub::Utils;
use Pub::WX::Main;
use Pub::WX::AppConfig;
use apps::fileClient::fcPrefs;
use base 'Wx::App';
# Stuff to begin my 'standard' application
# $debug_level = -5 if Cava::Packager::IsPackaged();
# set release debug level
openSTDOUTSemaphore("buddySTDOUT") if $ARGV[0];
setStandardDataDir("buddy");
$fc_prefs_filename = "$data_dir/fileClient.prefs";
$ini_file = "$data_dir/fileClient.ini";
my $frame;
sub OnInit
{
$frame = apps::fileClient::AppFrame->new();
if (!$frame)
{
warning(0,0,"unable to create frame");
return undef;
}
$frame->Show( 1 );
display(0,0,"fileClient.pm started");
return 1;
}
my $app = apps::fileClient::App->new();
Pub::WX::Main::run($app);
# This little snippet is required for my standard
# applications (needs to be put into)
display(0,0,"ending fileClient.pm ...");
$frame->DESTROY() if $frame;
$frame = undef;
# display(0,0,"finished fileClient.pm");
print "fileClient closed\r\n";
1;