def on_editContactItem_activate(self, widget): model, iterRow = self.mxit.contactStore.view.get_selection().get_selected() if not iterRow: errorDialog('Please select a contact first') row = model[iterRow] EditContactDialog(row[1], row[0], self.mxit)
def on_response_activate(self, dialog, response_id, *args): if not response_id == 1: dialog.destroy() return group = self.groupEntry.get_text() if group == '' or group == None: errorDialog('Please enter a group name') return self.mxit['contactStore'].createGroup(group) self.dialog.destroy()
def on_removeContactItem_activate(self, widget): from protocol.commands import RemoveContactMessage model, iterRow = self.mxit.contactStore.view.get_selection().get_selected() if not iterRow: errorDialog('Please select a contact first') return if model[iterRow][6] == CONTACT_TYPE_INFO or model[iterRow][6] == CONTACT_TYPE_GALLERY: errorDialog('Can\'t delete this contact') return message = RemoveContactMessage(model[iterRow][1]) self.mxit.sendMsg(message) del model[iterRow]
def on_challenge_error(self, error, *args): r = error.trap(challenge.CaptchaException, challenge.MXitServerException) print 'Error',error errorDialog(error.getErrorMessage()) if r == challenge.CaptchaException: self.load_captcha(self.challenge.challengeData['captcha']) self.animationCancelEvent.set() self.assistant.set_current_page(ACTIVATION_PAGE) elif r == challenge.MXitServerException: self.mxit.activation_window = ActivationWindow(self.mxit) self.assistant.hide() self.assistant.destroy() del self
def on_response(self, dialog, response_id): if not response_id == 0: dialog.destroy() return contactlist = [self.mxit.contactStore.contactContactList[button.get_name()] for button in self.contactButtonList if button.get_active()] if len(contactlist) == 0: errorDialog('Please select at least one contact') return groupname = self.builder.get_object('groupnameEntry').get_text() if len(groupname) == 0: errorDialog('Please create a name for your MultiMx') return dialog.destroy() message = CreateMultiMX(groupname, contactlist) self.mxit.send_message(message)
def on_registerButton_activated(self, *args): nickname = self.builder.get_object('nicknameEntry').get_text() pin = self.builder.get_object('pinEntry').get_text() dob = self.dobEntry.get_text() if self.builder.get_object('maleButton').get_active(): gender = 'male' else: gender = 'female' location = self.builder.get_object('locationEntry').get_text() language = self.builder.get_object('languageEntry').get_text() if not nickname: errorDialog("Please enter a nickname") return try: int(pin) if len(str(pin)) <4: raise ValueError except ValueError: errorDialog("Password must be a number and more than 4 digits") return self.applicationSession['tempPassword'] = pin #Todo: use a regular expression to check whether in correct format if len(dob) < 10: errorDialog("Please enter your Date of Birth") return if not len(location): errorDialog("Please enter a location") return if not len(language): errorDialog("Please enter a language") return message = RegistrationMessage(pin, nickname, dob, gender, location, language, self.applicationSession) self.applicationSession['protocolInstance'].sendMsg(message) self.dialog.destroy()
def on_response_activate(self, dialog, response_id, *args): if not response_id == 1: dialog.destroy() return contactAddress = self.contactAddressEntry.get_text() if not len(contactAddress): errorDialog('Please enter cellphone number to invite') nickname = self.nicknameEntry.get_text() #Todo: Check whether this nickname exists if not len(nickname): errorDialog('Please enter nickname for contact') #Todo: add support for groups inviteMessage = self.inviteMessageEntry.get_text() #Type is always 0, MXit message = InviteMessage(contactAddress, nickname, inviteMessage) self.mxit.sendMsg(message) self.dialog.destroy()
def on_response(self, dialog, response_id, *args): #If we get a response other then login return if not response_id == 0: return passwordEntry = self.builder.get_object('passwordEntry') password = passwordEntry.get_text() self.mxit.settings['tempPassword'] = password #Validation try: int(password) if len(password)<4: log.msg('< 4') raise ValueError except ValueError: errorDialog('Password must be a number and more than 4 characters') return self.mxit.settings['autoLogin'] = self.builder.get_object('rememberButton').get_active() self.mxit.do_login(password) dialog.destroy()
def handle_invite_contact(errorCode, errorMessage, message, mxit): if not errorCode == 0: errorDialog(errorMessage+' Try using country code (e.g. 27) instead of 0 in the cellphone number')