Changeset 215:bff7327b2da0 for src


Ignore:
Timestamp:
06/01/12 17:24:26 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added support for flying without logging in

Location:
src/mlx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/acft.py

    r211 r215  
    8989        # queried from it, so the model should have a reference to the GUI as
    9090        # well and access such data via the GUI!
    91         if config.onlineACARS and not flight.entranceExam:
     91        if config.onlineACARS and flight.loggedIn and not flight.entranceExam:
    9292            self._checkers.append(checks.ACARSSender(flight._gui))
    9393
     
    214214                config = flight.config
    215215                if config.onlineGateSystem and \
     216                   flight.loggedIn and \
    216217                   not flight.entranceExam and \
    217218                   bookedFlight.arrivalICAO=="LHBP" and \
  • src/mlx/flight.py

    r184 r215  
    6666        """Get the flight stage."""
    6767        return self._stage
     68
     69    @property
     70    def loggedIn(self):
     71        """Indicate if the user has logged in properly."""
     72        return self._gui.loggedIn
    6873
    6974    @property
  • src/mlx/gui/flight.py

    r214 r215  
    260260        table.attach(self._entranceExam, 1, 2, 3, 4, ypadding = 12)
    261261
     262        self.addButton(xstr("button_offline"),
     263                       clicked = self._offlineClicked,
     264                       tooltip = xstr("button_offline_tooltip"))
     265
    262266        self._loginButton = self.addButton(xstr("button_login"), default = True)
    263267        self._loginButton.connect("clicked", self._loginClicked)
     
    270274        return self._entranceExam.get_active() and \
    271275               self._pilotID.get_text()!=""
     276
     277    @property
     278    def pilotID(self):
     279        """Get the pilot ID, if given."""
     280        return self._pilotID.get_text()
    272281
    273282    def activate(self):
     
    301310        self._loginButton.set_sensitive(pilotID!="" and
    302311                                        (password!="" or entranceExam))
     312
     313    def _offlineClicked(self, button):
     314        """Called when the offline button was clicked."""
     315        self._wizard.nextPage()
    303316
    304317    def _loginClicked(self, button):
     
    414427        self._flights = []
    415428        self._listStore.clear()
    416         for flight in self._wizard.loginResult.flights:
    417             self._addFlight(flight)
     429        if self._wizard.loggedIn:
     430            for flight in self._wizard.loginResult.flights:
     431                self._addFlight(flight)
    418432
    419433    def _addFlight(self, flight):
     
    525539        flight = self._wizard._bookedFlight
    526540        if self._wizard.gui.config.onlineGateSystem and \
    527            not self._wizard.entranceExam:
     541           self._wizard.loggedIn and not self._wizard.entranceExam:
    528542            if flight.departureICAO=="LHBP":
    529543                self._wizard.getFleet(self._fleetRetrieved)
     
    22212235        """Called when the forward button is clicked."""
    22222236        if self._wizard.gui.config.onlineGateSystem and \
    2223            not self._completed and \
     2237           self._wizard.loggedIn and not self._completed and \
    22242238           self._wizard.bookedFlight.arrivalICAO=="LHBP" and \
    22252239           not self._wizard.entranceExam:
     
    24332447
    24342448        self._flightType.set_active(-1)
    2435         self._onlineFlight.set_active(True)
     2449        self._onlineFlight.set_active(self._wizard.loggedIn)
    24362450
    24372451        self._gatesModel.clear()
    24382452        if self._wizard.gui.config.onlineGateSystem and \
     2453           self._wizard.loggedIn and \
    24392454           self._wizard.bookedFlight.arrivalICAO=="LHBP" and \
    24402455           not self._wizard.entranceExam:
     
    24972512        bookedFlight = gui.bookedFlight
    24982513        tm = time.gmtime()
    2499        
    2500         fileName = "%s %s %02d%02d %s-%s.pirep" % \
    2501                    (gui.loginResult.pilotID,
    2502                     str(bookedFlight.departureTime.date()),
     2514
     2515        pilotID = self._wizard.pilotID
     2516        if pilotID: pilotID += " "
     2517        fileName = "%s%s %02d%02d %s-%s.pirep" % \
     2518                   (pilotID, str(bookedFlight.departureTime.date()),
    25032519                    tm.tm_hour, tm.tm_min,
    25042520                    bookedFlight.departureICAO,
     
    25842600        self._pirepSent = returned and result.success
    25852601        if self._wizard.gui.config.onlineGateSystem and \
    2586            not self._wizard.entranceExam and \
     2602           self._wizard.loggedIn and not self._wizard.entranceExam and \
    25872603           returned and result.success:
    25882604            bookedFlight = self._wizard.bookedFlight
     
    26602676
    26612677    @property
     2678    def pilotID(self):
     2679        """Get the pilot ID, if given."""
     2680        return self._loginPage.pilotID
     2681
     2682    @property
    26622683    def entranceExam(self):
    26632684        """Get whether an entrance exam is about to be taken."""
    26642685        return self._loginPage.entranceExam
     2686
     2687    @property
     2688    def loggedIn(self):
     2689        """Indicate if there was a successful login."""
     2690        return self._loginResult is not None
    26652691       
    26662692    @property
  • src/mlx/gui/gui.py

    r208 r215  
    186186        """Get whether an entrance exam is about to be taken."""
    187187        return self._wizard.entranceExam
     188
     189    @property
     190    def loggedIn(self):
     191        """Indicate if the user has logged in properly."""
     192        return self._wizard.loggedIn
    188193       
    189194    @property
     
    432437        self._logView.get_buffer().set_text("")
    433438
    434         self._wizard.reloadFlights(self._handleReloadResult)
     439        if self.loggedIn:
     440            self._wizard.reloadFlights(self._handleReloadResult)
     441        else:
     442            self._wizard.reset(None)
    435443
    436444    def _handleReloadResult(self, returned, result):
  • src/mlx/i18n.py

    r214 r215  
    229229        self.add("login_entranceExam_tooltip",
    230230                 "Check this to log in to take your entrance exam.")
     231        self.add("button_offline", "Fl_y offline")
     232        self.add("button_offline_tooltip",
     233                 "Click this button to fly offline, without logging in "
     234                 "to the MAVA website.")
    231235        self.add("button_login", "Logi_n")
    232236        self.add("login_button_tooltip", "Click to log in.")
Note: See TracChangeset for help on using the changeset viewer.