Mercurial > libervia-desktop-kivy
diff cagou/core/profile_manager.py @ 491:203755bbe0fe
massive refactoring from camelCase -> snake_case. See backend commit log for more details
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:44:32 +0200 |
parents | 3c9ba4a694ef |
children |
line wrap: on
line diff
--- a/cagou/core/profile_manager.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/profile_manager.py Sat Apr 08 13:44:32 2023 +0200 @@ -45,21 +45,21 @@ super(NewProfileScreen, self).__init__(name='new_profile') self.pm = pm - def onCreationFailure(self, failure): + def on_creation_failure(self, failure): msg = [l for l in str(failure).split('\n') if l][-1] self.error_msg = str(msg) - def onCreationSuccess(self, profile): + def on_creation_success(self, profile): self.pm.profiles_screen.reload() - G.host.bridge.profileStartSession( + G.host.bridge.profile_start_session( self.password.text, profile, - callback=lambda __: self._sessionStarted(profile), - errback=self.onCreationFailure) + callback=lambda __: self._session_started(profile), + errback=self.on_creation_failure) - def _sessionStarted(self, profile): + def _session_started(self, profile): jid = self.jid.text.strip() - G.host.bridge.setParam("JabberID", jid, "Connection", -1, profile) - G.host.bridge.setParam("Password", self.password.text, "Connection", -1, profile) + G.host.bridge.param_set("JabberID", jid, "Connection", -1, profile) + G.host.bridge.param_set("Password", self.password.text, "Connection", -1, profile) self.pm.screen_manager.transition.direction = 'right' self.pm.screen_manager.current = 'profiles' @@ -67,10 +67,10 @@ name = self.profile_name.text.strip() # XXX: we use XMPP password for profile password to simplify # if user want to change profile password, he can do it in preferences - G.host.bridge.profileCreate( + G.host.bridge.profile_create( name, self.password.text, '', - callback=lambda: self.onCreationSuccess(name), - errback=self.onCreationFailure) + callback=lambda: self.on_creation_success(name), + errback=self.on_creation_failure) class DeleteProfilesScreen(Screen): @@ -79,12 +79,12 @@ self.pm = pm super(DeleteProfilesScreen, self).__init__(name='delete_profiles') - def doDelete(self): + def do_delete(self): """This method will delete *ALL* selected profiles""" - to_delete = self.pm.getProfiles() + to_delete = self.pm.get_profiles() deleted = [0] - def deleteInc(): + def delete_inc(): deleted[0] += 1 if deleted[0] == len(to_delete): self.pm.profiles_screen.reload() @@ -93,8 +93,8 @@ for profile in to_delete: log.info("Deleteing profile [{}]".format(profile)) - G.host.bridge.asyncDeleteProfile( - profile, callback=deleteInc, errback=deleteInc) + G.host.bridge.profile_delete_async( + profile, callback=delete_inc, errback=delete_inc) class ProfilesScreen(Screen): @@ -106,7 +106,7 @@ super(ProfilesScreen, self).__init__(name='profiles') self.reload() - def _profilesListGetCb(self, profiles): + def _profiles_list_get_cb(self, profiles): profiles.sort() self.profiles = profiles for idx, profile in enumerate(profiles): @@ -121,7 +121,7 @@ def reload(self): """Reload profiles list""" self.layout.clear_widgets() - G.host.bridge.profilesListGet(callback=self._profilesListGetCb) + G.host.bridge.profiles_list_get(callback=self._profiles_list_get_cb) class ProfileManager(QuickProfileManager, BoxLayout): @@ -141,20 +141,20 @@ self.screen_manager.add_widget(self.delete_profiles_screen) self.add_widget(self.screen_manager) - def closeUI(self, xmlui, reason=None): + def close_ui(self, xmlui, reason=None): self.screen_manager.transition.direction = 'right' self.screen_manager.current = 'profiles' - def showUI(self, xmlui): - xmlui.setCloseCb(self.closeUI) + def show_ui(self, xmlui): + xmlui.set_close_cb(self.close_ui) if xmlui.type == 'popup': - xmlui.bind(on_touch_up=lambda obj, value: self.closeUI(xmlui)) + xmlui.bind(on_touch_up=lambda obj, value: self.close_ui(xmlui)) self.xmlui_screen.clear_widgets() self.xmlui_screen.add_widget(xmlui) self.screen_manager.transition.direction = 'left' self.screen_manager.current = 'xmlui' - def selectProfile(self, profile_item): + def select_profile(self, profile_item): if not profile_item.selected: return def authenticate_cb(data, cb_id, profile): @@ -166,13 +166,13 @@ # state may have been modified so we need to be sure it's down profile_item.state = 'down' self.selected = profile_item - G.host.actionManager(data, callback=authenticate_cb, ui_show_cb=self.showUI, + G.host.action_manager(data, callback=authenticate_cb, ui_show_cb=self.show_ui, profile=profile) - G.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, + G.host.action_launch(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=profile_item.text) - def getProfiles(self): + def get_profiles(self): # for now we restrict to a single profile in Cagou # TODO: handle multi-profiles return [self.selected.text] if self.selected else []