comparison src/plugins/plugin_misc_account.py @ 587:952322b1d490

Remove trailing whitespaces.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:34 +0100
parents ca13633d3b6b
children beaf6bec2fcd
comparison
equal deleted inserted replaced
586:6a718ede8be1 587:952322b1d490
50 50
51 RESERVED = ['libervia'] 51 RESERVED = ['libervia']
52 52
53 class ProsodyRegisterProtocol(protocol.ProcessProtocol): 53 class ProsodyRegisterProtocol(protocol.ProcessProtocol):
54 """ Try to register an account with prosody """ 54 """ Try to register an account with prosody """
55 55
56 def __init__(self, password, deferred = None): 56 def __init__(self, password, deferred = None):
57 self.password = password 57 self.password = password
58 self.deferred = deferred 58 self.deferred = deferred
59 self.data = '' 59 self.data = ''
60 60
61 def connectionMade(self): 61 def connectionMade(self):
62 self.transport.write("%s\n%s" % ((self.password.encode('utf-8'),)*2)) 62 self.transport.write("%s\n%s" % ((self.password.encode('utf-8'),)*2))
63 self.transport.closeStdin() 63 self.transport.closeStdin()
64 64
65 65
66 def outReceived(self, data): 66 def outReceived(self, data):
67 self.data += data 67 self.data += data
68 68
69 def errReceived(self, data): 69 def errReceived(self, data):
70 self.data += data 70 self.data += data
71 71
72 def processEnded(self, reason): 72 def processEnded(self, reason):
73 if (reason.value.exitCode == 0): 73 if (reason.value.exitCode == 0):
74 info(_('Prosody registration success')) 74 info(_('Prosody registration success'))
75 self.deferred.callback(None) 75 self.deferred.callback(None)
76 else: 76 else:
95 else: 95 else:
96 self._prosody_path = dirname(paths[0]) 96 self._prosody_path = dirname(paths[0])
97 info(_('Prosody path found: %s') % (self._prosody_path,)) 97 info(_('Prosody path found: %s') % (self._prosody_path,))
98 98
99 def _registerAccount(self, email, password, profile): 99 def _registerAccount(self, email, password, profile):
100 100
101 """ 101 """
102 #Password Generation 102 #Password Generation
103 #_charset = [chr(i) for i in range(0x21,0x7F)] #XXX: this charset seems to have some issues with openfire 103 #_charset = [chr(i) for i in range(0x21,0x7F)] #XXX: this charset seems to have some issues with openfire
104 _charset = [chr(i) for i in range(0x30,0x3A) + range(0x41,0x5B) + range (0x61,0x7B)] 104 _charset = [chr(i) for i in range(0x30,0x3A) + range(0x41,0x5B) + range (0x61,0x7B)]
105 import random 105 import random
115 d = self.host.memory.asyncCreateProfile(profile) 115 d = self.host.memory.asyncCreateProfile(profile)
116 d.addCallback(self._profileRegistered, email, password, profile) 116 d.addCallback(self._profileRegistered, email, password, profile)
117 return d 117 return d
118 118
119 def _profileRegistered(self, result, email, password, profile): 119 def _profileRegistered(self, result, email, password, profile):
120 120
121 #FIXME: values must be in a config file instead of hardcoded 121 #FIXME: values must be in a config file instead of hardcoded
122 self.host.memory.setParam("JabberID", "%s@%s/%s" % (profile, _NEW_ACCOUNT_DOMAIN, _NEW_ACCOUNT_RESOURCE), "Connection", profile) 122 self.host.memory.setParam("JabberID", "%s@%s/%s" % (profile, _NEW_ACCOUNT_DOMAIN, _NEW_ACCOUNT_RESOURCE), "Connection", profile)
123 self.host.memory.setParam("Server", _NEW_ACCOUNT_SERVER, "Connection", profile) 123 self.host.memory.setParam("Server", _NEW_ACCOUNT_SERVER, "Connection", profile)
124 self.host.memory.setParam("Password", password, "Connection", profile) 124 self.host.memory.setParam("Password", password, "Connection", profile)
125 #and the account 125 #and the account
126 126
127 #XXX: we use "prosodyctl adduser" because "register" doesn't check conflict 127 #XXX: we use "prosodyctl adduser" because "register" doesn't check conflict
128 # and just change the password if the account already exists 128 # and just change the password if the account already exists
129 d = defer.Deferred() 129 d = defer.Deferred()
130 prosody_reg = ProsodyRegisterProtocol(password, d) 130 prosody_reg = ProsodyRegisterProtocol(password, d)
131 prosody_exe = join (self._prosody_path, _PROSODYCTL) 131 prosody_exe = join (self._prosody_path, _PROSODYCTL)
144 print ("Account creation email sent to %s" % email) 144 print ("Account creation email sent to %s" % email)
145 145
146 def email_ko(ignore): 146 def email_ko(ignore):
147 #TODO: return error code to user 147 #TODO: return error code to user
148 error ("Failed to send email to %s" % email) 148 error ("Failed to send email to %s" % email)
149 149
150 body = (u"""Welcome to Libervia, a Salut à Toi project part 150 body = (u"""Welcome to Libervia, a Salut à Toi project part
151 151
152 /!\\ WARNING, THIS IS ONLY A TECHNICAL DEMO, DON'T USE THIS ACCOUNT FOR ANY SERIOUS PURPOSE /!\\ 152 /!\\ WARNING, THIS IS ONLY A TECHNICAL DEMO, DON'T USE THIS ACCOUNT FOR ANY SERIOUS PURPOSE /!\\
153 153
154 Here are your connection informations: 154 Here are your connection informations: