~ubuntu-branches/ubuntu/quantal/mago/quantal

« back to all changes in this revision

Viewing changes to mago/application/seahorse.py

  • Committer: Bazaar Package Importer
  • Author(s): Ara Pulido
  • Date: 2010-12-03 16:08:32 UTC
  • Revision ID: james.westby@ubuntu.com-20101203160832-97pz2nxwmo54iwfk
Tags: 0.3-0ubuntu3
* Updated from trunk
 + Added new applications to our tests base
 + Fixes LP: #682845 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
1
3
PACKAGE = "mago"
2
4
 
3
 
#-*- coding:utf-8 -*-
4
5
"""
5
6
This is the "Seahorse" module.
6
7
 
28
29
    WINDOW       = _("frmPasswordsandEncryptionKeys")
29
30
    LAUNCHER     = "seahorse"
30
31
    MNU_NEWKEY   = _("mnuNew")
31
 
    NEWKEY_DLG   = _("Create New ...")
 
32
    NEWKEY_DLG   = _("Create New*")
32
33
    BTN_CONTINUE = _("btnContinue")
33
34
    TYPE_PGP            = _("PGP Key")
34
35
    NEWPGP_DLG          = _("dlgNewPGPKey")
51
52
    BTN_NEWSSH_CREATE   = _("Just Create Key")
52
53
    TAB_PERSONAL_KEYS   = _("My Personal Keys")
53
54
    TAB_LIST            = "ptl0"
54
 
    TBL_PERSONAL_KEYS   = "tbl0"
 
55
    TBL_PERSONAL_KEYS   = "ttbl1"
55
56
    LBL_DELETE_KEY_Q   = _("lblOneormoreofthedeletedkeysareprivatekeys.Areyousureyouwanttoproceed?")
56
57
 
57
58
    def __init__(self):
68
69
        
69
70
        seahorse = ooldtp.context(self.name)
70
71
        
71
 
        try:
72
 
            mnu_new_key = seahorse.getchild(self.MNU_NEWKEY)
73
 
        except ldtp.LdtpExecutionError:
74
 
            raise ldtp.LdtpExecutionError, "The new key menu was not found."
75
 
 
76
 
        try:
77
 
            mnu_new_key.selectmenuitem() 
78
 
        except ldtp.LdtpExecutionError:
79
 
            raise ldtp.LdtpExecutionError, "There was a problem when selecting new key menu item."
80
 
 
81
 
        try:
82
 
            ldtp.waittillguiexist(self.NEWKEY_DLG)
83
 
            dlg_new_key = ooldtp.context(self.NEWKEY_DLG)
84
 
        except ldtp.LdtpExecutionError:
85
 
            raise ldtp.LdtpExecutionError, "The new key dialog was not found."
86
 
 
87
 
        try:
88
 
            table  = dlg_new_key.getchild(role = 'table')
89
 
            types_table = table[0]
90
 
 
91
 
            for i in range(0, types_table.getrowcount(), 1):
92
 
                text = types_table.getcellvalue(i, 1)
93
 
                candidate = text.split('\n')[0]
94
 
                if candidate == key_type:
95
 
                    types_table.selectrowindex(i)
96
 
                    break
97
 
                ldtp.wait(1)
98
 
        except ldtp.LdtpExecutionError:
99
 
            raise ldtp.LdtpExecutionError, "Error getting the key types table."
100
 
 
101
 
        try:
102
 
            btn_continue = dlg_new_key.getchild(self.BTN_CONTINUE)
103
 
        except ldtp.LdtpExecutionError:
104
 
            raise ldtp.LdtpExecutionError, "The continue button at the new key dialog was not found."
105
 
 
106
 
        try:
107
 
            btn_continue.click() 
108
 
        except ldtp.LdtpExecutionError:
109
 
            raise ldtp.LdtpExecutionError, "There was a problem when clicking the continue button."
 
72
        mnu_new_key = seahorse.getchild(self.MNU_NEWKEY)
 
73
        mnu_new_key.selectmenuitem() 
 
74
 
 
75
        ldtp.waittillguiexist(self.NEWKEY_DLG)
 
76
        dlg_new_key = ooldtp.context(self.NEWKEY_DLG)
 
77
 
 
78
        table  = dlg_new_key.getchild(role = 'table')
 
79
        types_table = table[0]
 
80
 
 
81
        for i in range(0, types_table.getrowcount(), 1):
 
82
            text = types_table.getcellvalue(i, 1)
 
83
            candidate = text.split('\n')[0]
 
84
            if candidate == key_type:
 
85
                types_table.selectrowindex(i)
 
86
                break
 
87
            ldtp.wait(1)
 
88
 
 
89
        btn_continue = dlg_new_key.getchild(self.BTN_CONTINUE)
 
90
 
 
91
        btn_continue.click() 
110
92
        
111
93
    def new_pgp_key(self, full_name, email, comment, passphrase):
112
94
        """
130
112
        
131
113
        self.new_key(self.TYPE_PGP)
132
114
 
133
 
        try:
134
 
            ldtp.waittillguiexist(self.NEWPGP_DLG)
135
 
            dlg_new_pgp = ooldtp.context(self.NEWPGP_DLG)
136
 
        except ldtp.LdtpExecutionError:
137
 
            raise ldtp.LdtpExecutionError, "The new key dialog was not found."
138
 
 
139
 
        try:
140
 
            txt_field = dlg_new_pgp.getchild(self.DLG_NEWPGP_FULLNAME)
141
 
        except ldtp.LdtpExecutionError:
142
 
            raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found."
143
 
        try:
144
 
            txt_field.settextvalue(full_name)
145
 
        except ldtp.LdtpExecutionError:
146
 
            raise ldtp.LdtpExecutionError, "There was an error when writing the text."
147
 
 
148
 
        try:
149
 
            txt_field = dlg_new_pgp.getchild(self.DLG_NEWPGP_EMAIL)
150
 
        except ldtp.LdtpExecutionError:
151
 
            raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found."
152
 
        try:
153
 
            txt_field.settextvalue(email)
154
 
        except ldtp.LdtpExecutionError:
155
 
            raise ldtp.LdtpExecutionError, "There was a problem when writing the text."
 
115
        ldtp.waittillguiexist(self.NEWPGP_DLG)
 
116
        dlg_new_pgp = ooldtp.context(self.NEWPGP_DLG)
 
117
 
 
118
        txt_field = dlg_new_pgp.getchild(self.DLG_NEWPGP_FULLNAME)
 
119
        txt_field.settextvalue(full_name)
 
120
 
 
121
        txt_field = dlg_new_pgp.getchild(self.DLG_NEWPGP_EMAIL)
 
122
        txt_field.settextvalue(email)
156
123
   
157
 
        try:
158
 
            txt_field = dlg_new_pgp.getchild(self.DLG_NEWPGP_COMMENT)
159
 
        except ldtp.LdtpExecutionError:
160
 
            raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found."
161
 
        try:
162
 
            txt_field.settextvalue(comment)
163
 
        except ldtp.LdtpExecutionError:
164
 
            raise ldtp.LdtpExecutionError, "There was a problem when writing the text."
165
 
 
166
 
        try:
167
 
            btn_create = dlg_new_pgp.getchild(self.BTN_NEWPGP_CREATE)
168
 
        except ldtp.LdtpExecutionError:
169
 
            raise ldtp.LdtpExecutionError, "The create button at the new PGP key dialog was not found."
170
 
 
171
 
        try:
172
 
            btn_create.click() 
173
 
        except ldtp.LdtpExecutionError:
174
 
            raise ldtp.LdtpExecutionError, "There was a problem when clicking the create button."
 
124
        txt_field = dlg_new_pgp.getchild(self.DLG_NEWPGP_COMMENT)
 
125
        txt_field.settextvalue(comment)
 
126
 
 
127
        btn_create = dlg_new_pgp.getchild(self.BTN_NEWPGP_CREATE)
 
128
        btn_create.click() 
175
129
       
176
 
        try:
177
 
            ldtp.waittillguiexist(self.DLG_NEWKEY_PASS)
178
 
            dlg_new_pgp_pass = ooldtp.context(self.DLG_NEWKEY_PASS)
179
 
        except ldtp.LdtpExecutionError:
180
 
            raise ldtp.LdtpExecutionError, "The new pgp key passphrase dialog was not found."
181
 
 
182
 
        try:
183
 
            ldtp.enterstring(passphrase)
184
 
            ldtp.enterstring("<tab>")
185
 
            ldtp.enterstring(passphrase)
186
 
        except ldtp.LdtpExecutionError:
187
 
            raise ldtp.LdtpExecutionError, "Error entering passphrase."
188
 
 
189
 
        try:
190
 
            btn_pass_ok = dlg_new_pgp_pass.getchild(self.BTN_PASS_OK)
191
 
        except ldtp.LdtpExecutionError:
192
 
            raise ldtp.LdtpExecutionError, "The OK button at the new PGP key passphrase dialog was not found."
193
 
 
194
 
        try:
195
 
            btn_pass_ok.click() 
196
 
        except ldtp.LdtpExecutionError:
197
 
            raise ldtp.LdtpExecutionError, "There was a problem when clicking the OK button."
198
 
 
199
 
        try:
200
 
            ldtp.waittillguiexist(self.DLG_GENERATING_KEY)
201
 
            while ldtp.guiexist(self.DLG_GENERATING_KEY) == 1:
202
 
                ldtp.wait(1)
203
 
        except ldtp.LdtpExecutionError:
204
 
            raise ldtp.LdtpExecutionError, "The new pgp generating key dialog was not found."
 
130
        ldtp.waittillguiexist(self.DLG_NEWKEY_PASS)
 
131
        dlg_new_pgp_pass = ooldtp.context(self.DLG_NEWKEY_PASS)
 
132
 
 
133
        # Entering the passphrase
 
134
        ldtp.enterstring(passphrase)
 
135
        ldtp.enterstring("<tab>")
 
136
        ldtp.enterstring(passphrase)
 
137
 
 
138
        btn_pass_ok = dlg_new_pgp_pass.getchild(self.BTN_PASS_OK)
 
139
 
 
140
        btn_pass_ok.click() 
 
141
 
 
142
        ldtp.waittillguiexist(self.DLG_GENERATING_KEY)
 
143
        while ldtp.guiexist(self.DLG_GENERATING_KEY) == 1:
 
144
            ldtp.wait(1)
205
145
 
206
146
        # Add key name to generated key list, so we know to delete it later.
207
147
        self.generated_keys.append('  '.join([full_name, email, "'"+comment+"'"]))
230
170
        
231
171
        self.new_key(self.TYPE_SSH)
232
172
 
233
 
        try:
234
 
            ldtp.waittillguiexist(self.NEWSSH_DLG)
235
 
            dlg_new_ssh = ooldtp.context(self.NEWSSH_DLG)
236
 
        except ldtp.LdtpExecutionError:
237
 
            raise ldtp.LdtpExecutionError, "The new key dialog was not found."
 
173
        ldtp.waittillguiexist(self.NEWSSH_DLG)
 
174
        dlg_new_ssh = ooldtp.context(self.NEWSSH_DLG)
238
175
 
239
 
        try:
240
 
            txt_field = dlg_new_ssh.getchild(self.DLG_NEWSSH_DESC)
241
 
        except ldtp.LdtpExecutionError:
242
 
            raise ldtp.LdtpExecutionError, "The " + self.DLG_NEWSSH_DESC + " text field was not found."
243
 
        try:
244
 
            txt_field.settextvalue(description)
245
 
        except ldtp.LdtpExecutionError:
246
 
            raise ldtp.LdtpExecutionError, "There was an error when writing the text."
 
176
        txt_field = dlg_new_ssh.getchild(self.DLG_NEWSSH_DESC)
 
177
        txt_field.settextvalue(description)
247
178
 
248
179
        if set_up == True:
249
 
            try:
250
 
                btn_create = dlg_new_ssh.getchild(self.BTN_NEWSSH_CREATE_AND_SETUP)
251
 
            except ldtp.LdtpExecutionError:
252
 
                raise ldtp.LdtpExecutionError, "The create button at the new PGP key dialog was not found."
253
 
 
 
180
            btn_create = dlg_new_ssh.getchild(self.BTN_NEWSSH_CREATE_AND_SETUP)
254
181
        else:
255
 
            try:
256
 
                btn_create = dlg_new_ssh.getchild(self.BTN_NEWSSH_CREATE)
257
 
            except ldtp.LdtpExecutionError:
258
 
                raise ldtp.LdtpExecutionError, "The create button at the new PGP key dialog was not found."
 
182
            btn_create = dlg_new_ssh.getchild(self.BTN_NEWSSH_CREATE)
259
183
 
260
 
        try:
261
 
            btn_create.click() 
262
 
        except ldtp.LdtpExecutionError:
263
 
            raise ldtp.LdtpExecutionError, "There was a problem when clicking the create button."
 
184
        btn_create.click() 
264
185
      
265
186
 
266
 
        try:
267
 
            ldtp.waittillguiexist(self.DLG_NEWKEY_PASS)
268
 
            dlg_new_key_pass = ooldtp.context(self.DLG_NEWKEY_PASS)
269
 
        except ldtp.LdtpExecutionError:
270
 
            raise ldtp.LdtpExecutionError, "The new key passphrase dialog was not found."
 
187
        ldtp.waittillguiexist(self.DLG_NEWKEY_PASS)
 
188
        dlg_new_key_pass = ooldtp.context(self.DLG_NEWKEY_PASS)
271
189
 
272
 
        try:
273
 
            ldtp.enterstring(passphrase)
274
 
            ldtp.enterstring("<tab>")
275
 
            ldtp.enterstring(passphrase)
276
 
        except ldtp.LdtpExecutionError:
277
 
            raise ldtp.LdtpExecutionError, "Error entering passphrase."
 
190
        # Entering the passphrase
 
191
        ldtp.enterstring(passphrase)
 
192
        ldtp.enterstring("<tab>")
 
193
        ldtp.enterstring(passphrase)
278
194
 
279
 
        try:
280
 
            btn_pass_ok = dlg_new_key_pass.getchild(self.BTN_PASS_OK)
281
 
        except ldtp.LdtpExecutionError:
282
 
            raise ldtp.LdtpExecutionError, "The OK button at the new key passphrase dialog was not found."
283
 
 
284
 
        try:
285
 
            btn_pass_ok.click() 
286
 
        except ldtp.LdtpExecutionError:
287
 
            raise ldtp.LdtpExecutionError, "There was a problem when clicking the OK button."
 
195
        btn_pass_ok = dlg_new_key_pass.getchild(self.BTN_PASS_OK)
 
196
        btn_pass_ok.click() 
288
197
 
289
198
        if set_up == True and login is not None:
290
199
 
291
 
            try:
292
 
                ldtp.waittillguiexist(self.DLG_SET_UP)
293
 
                dlg_set_up_computer = ooldtp.context(self.DLG_SET_UP)
294
 
            except ldtp.LdtpExecutionError:
295
 
                raise ldtp.LdtpExecutionError, "The set up computer dialog was not found."
 
200
            ldtp.waittillguiexist(self.DLG_SET_UP)
 
201
            dlg_set_up_computer = ooldtp.context(self.DLG_SET_UP)
296
202
 
297
 
            try:
298
 
                txt_field = dlg_set_up_computer.getchild(self.TXT_SET_UP_LOGIN)
299
 
            except ldtp.LdtpExecutionError:
300
 
                raise ldtp.LdtpExecutionError, "The " + self.TXT_SET_UP_LOGIN + " text field was not found."
301
 
            try:
302
 
                txt_field.settextvalue(login)
303
 
            except ldtp.LdtpExecutionError:
304
 
                raise ldtp.LdtpExecutionError, "There was an error when writing the text."
 
203
            txt_field = dlg_set_up_computer.getchild(self.TXT_SET_UP_LOGIN)
 
204
            txt_field.settextvalue(login)
305
205
 
306
206
        if set_up == True:
307
 
            try:
308
 
                txt_field = dlg_set_up_computer.getchild(self.TXT_SET_UP_COMPUTER)
309
 
            except ldtp.LdtpExecutionError:
310
 
                raise ldtp.LdtpExecutionError, "The " + self.TXT_SET_UP_COMPUTER + " text field was not found."
311
 
            try:
312
 
                txt_field.settextvalue(computer)
313
 
            except ldtp.LdtpExecutionError:
314
 
                raise ldtp.LdtpExecutionError, "There was an error when writing the text."
315
 
 
316
 
            try:
317
 
                btn_set_up = dlg_set_up_computer.getchild(self.BTN_SET_UP)
318
 
            except ldtp.LdtpExecutionError:
319
 
                raise ldtp.LdtpExecutionError, "The set up button was not found."
320
 
 
321
 
            try:
322
 
                btn_set_up.click() 
323
 
            except ldtp.LdtpExecutionError:
324
 
                raise ldtp.LdtpExecutionError, "There was a problem when clicking the set up button."
325
 
            
326
 
        try:
327
 
            while ldtp.guiexist(self.DLG_CREATING_SSH) == 1:
328
 
                ldtp.wait(1)
329
 
            
330
 
        except ldtp.LdtpExecutionError:
331
 
            raise ldtp.LdtpExecutionError, "The creating key dialog was not found."
 
207
            txt_field = dlg_set_up_computer.getchild(self.TXT_SET_UP_COMPUTER)
 
208
            txt_field.settextvalue(computer)
 
209
 
 
210
            btn_set_up = dlg_set_up_computer.getchild(self.BTN_SET_UP)
 
211
            btn_set_up.click() 
 
212
            
 
213
        while ldtp.guiexist(self.DLG_CREATING_SSH) == 1:
 
214
            ldtp.wait(1)
 
215
            
332
216
        # Add key name to generated key list, so we know to delete it later.
333
217
        self.generated_keys.append(description)
334
218
 
362
246
        seahorse = ooldtp.context(self.name)
363
247
 
364
248
        selected_tab = seahorse.getchild(tab_name)
365
 
        table = selected_tab.getchild(role="table")
 
249
        table = selected_tab.getchild(role="tree_table")
366
250
        
367
251
        return bool(table[0].doesrowexist(name))
368
252
 
372
256
        tbl_personal_keys = seahorse.getchild(self.TBL_PERSONAL_KEYS)
373
257
        mnu_delete = seahorse.getchild(_('mnuDelete'))
374
258
        dlg_question = ooldtp.context('dlgQuestion')
375
 
        
 
259
 
376
260
        try:
377
261
            tbl_personal_keys.selectrow(key)
378
262
        except ldtp.LdtpExecutionError: