source: extras/pLoader/trunk/src/Uploader/GUI/wxLoginDlg.pm @ 3232

Last change on this file since 3232 was 3232, checked in by ronosman, 15 years ago

Bug 963. Work offline mode ignored after first login failure.

  • Property svn:eol-style set to LF
File size: 3.6 KB
Line 
1# +-----------------------------------------------------------------------+
2# | pLoader - a Perl photo uploader for Piwigo                            |
3# +-----------------------------------------------------------------------+
4# | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
5# +-----------------------------------------------------------------------+
6# | This program is free software; you can redistribute it and/or modify  |
7# | it under the terms of the GNU General Public License as published by  |
8# | the Free Software Foundation                                          |
9# |                                                                       |
10# | This program is distributed in the hope that it will be useful, but   |
11# | WITHOUT ANY WARRANTY; without even the implied warranty of            |
12# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
13# | General Public License for more details.                              |
14# |                                                                       |
15# | You should have received a copy of the GNU General Public License     |
16# | along with this program; if not, write to the Free Software           |
17# | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
18# | USA.                                                                  |
19# +-----------------------------------------------------------------------+
20package Uploader::GUI::wxLoginDlg;
21use strict;
22use Wx qw/
23             wxDefaultSize
24             wxDefaultPosition
25             wxID_CANCEL
26             wxID_OK
27             wxGREEN
28         /;
29use base qw/Wx::Dialog Class::Accessor::Fast/;
30use Wx::Event qw/
31                    EVT_BUTTON
32                /;
33
34__PACKAGE__->mk_accessors( 
35    qw/
36           btok
37           url
38           username
39           password
40           use_offline
41      / 
42);
43
44
45sub new {
46    my ($this, $params) = @_;
47    #on recupere le nom de la classe en fonction du type d'appel de la méthode.
48    my $class = ref($this) || $this;
49
50
51    my $self = $class->SUPER::new( undef, -1, $params->{title}, wxDefaultPosition, wxDefaultSize);
52    # load controls
53    &main::Login($self, 1);
54
55    $self->use_offline(
56        $params->{use_offline}
57    );
58   
59    $self->url(
60        $params->{site_url}
61    );
62
63    $self->username(
64        $params->{site_username}
65    );
66
67    $self->password(
68        $params->{site_password}
69    );
70
71    $self->_initEventHandlers();
72   
73    $self->btok( $self->FindWindow($main::ID_PWG_OK) );
74
75    $self->FindWindow($main::ID_PWG_URL)->SetValue(
76        $self->url->()
77    );
78   
79   
80    $self->FindWindow($main::ID_PWG_USERNAME)->SetValue(
81        $self->username->() 
82    );
83   
84    $self->FindWindow($main::ID_PWG_PASSWORD)->SetValue( 
85        $self->password->() 
86    );
87     
88    $self;   
89}
90
91
92sub _initEventHandlers {
93    my ( $self ) = @_;
94   
95    EVT_BUTTON( $self, $main::ID_PWG_OK, \&OnLoginOK );
96    EVT_BUTTON( $self, $main::ID_PWG_CANCEL, \&OnLoginCancel );
97    EVT_BUTTON( $self, $main::ID_PWG_OFFLINE, \&OnLoginOffline );
98   
99       
100}
101
102sub OnLoginOffline {
103    my ( $self, $event ) = @_;
104
105    $self->use_offline->(1);
106       
107    $self->EndModal(2);
108}
109
110
111sub OnLoginOK {
112    my ( $self, $event ) = @_;
113   
114    $self->url->(
115        $self->FindWindow($main::ID_PWG_URL)->GetValue   
116    );
117
118    $self->username->(
119        $self->FindWindow($main::ID_PWG_USERNAME)->GetValue
120    );
121   
122    $self->password->(
123        $self->FindWindow($main::ID_PWG_PASSWORD)->GetValue
124    );
125
126    $self->EndModal(1);
127}
128
129sub OnLoginCancel {
130    my ( $self, $event ) = @_;
131   
132   
133    $self->EndModal(0);
134 
135}
136
137
1381;
Note: See TracBrowser for help on using the repository browser.