16 class SvnDialogMixin: |
16 class SvnDialogMixin: |
17 """ |
17 """ |
18 Class implementing a dialog mixin providing common callback methods for |
18 Class implementing a dialog mixin providing common callback methods for |
19 the pysvn client. |
19 the pysvn client. |
20 """ |
20 """ |
|
21 |
21 def __init__(self, log=""): |
22 def __init__(self, log=""): |
22 """ |
23 """ |
23 Constructor |
24 Constructor |
24 |
25 |
25 @param log optional log message (string) |
26 @param log optional log message (string) |
26 """ |
27 """ |
27 self.shouldCancel = False |
28 self.shouldCancel = False |
28 self.logMessage = log |
29 self.logMessage = log |
29 |
30 |
30 def _cancel(self): |
31 def _cancel(self): |
31 """ |
32 """ |
32 Protected method to request a cancellation of the current action. |
33 Protected method to request a cancellation of the current action. |
33 """ |
34 """ |
34 self.shouldCancel = True |
35 self.shouldCancel = True |
35 |
36 |
36 def _reset(self): |
37 def _reset(self): |
37 """ |
38 """ |
38 Protected method to reset the internal state of the dialog. |
39 Protected method to reset the internal state of the dialog. |
39 """ |
40 """ |
40 self.shouldCancel = False |
41 self.shouldCancel = False |
41 |
42 |
42 def _clientCancelCallback(self): |
43 def _clientCancelCallback(self): |
43 """ |
44 """ |
44 Protected method called by the client to check for cancellation. |
45 Protected method called by the client to check for cancellation. |
45 |
46 |
46 @return flag indicating a cancellation |
47 @return flag indicating a cancellation |
47 """ |
48 """ |
48 QApplication.processEvents() |
49 QApplication.processEvents() |
49 return self.shouldCancel |
50 return self.shouldCancel |
50 |
51 |
51 def _clientLoginCallback(self, realm, username, may_save): |
52 def _clientLoginCallback(self, realm, username, may_save): |
52 """ |
53 """ |
53 Protected method called by the client to get login information. |
54 Protected method called by the client to get login information. |
54 |
55 |
55 @param realm name of the realm of the requested credentials (string) |
56 @param realm name of the realm of the requested credentials (string) |
56 @param username username as supplied by subversion (string) |
57 @param username username as supplied by subversion (string) |
57 @param may_save flag indicating, that subversion is willing to save |
58 @param may_save flag indicating, that subversion is willing to save |
58 the answers returned (boolean) |
59 the answers returned (boolean) |
59 @return tuple of four values (retcode, username, password, save). |
60 @return tuple of four values (retcode, username, password, save). |
61 by subversion, username and password contain the relevant data |
62 by subversion, username and password contain the relevant data |
62 as strings and save is a flag indicating, that username and |
63 as strings and save is a flag indicating, that username and |
63 password should be saved. |
64 password should be saved. |
64 """ |
65 """ |
65 from .SvnLoginDialog import SvnLoginDialog |
66 from .SvnLoginDialog import SvnLoginDialog |
66 |
67 |
67 with EricOverridenCursor(): |
68 with EricOverridenCursor(): |
68 parent = isinstance(self, QWidget) and self or None |
69 parent = isinstance(self, QWidget) and self or None |
69 dlg = SvnLoginDialog(realm, username, may_save, parent) |
70 dlg = SvnLoginDialog(realm, username, may_save, parent) |
70 res = dlg.exec() |
71 res = dlg.exec() |
71 |
72 |
72 if res == QDialog.DialogCode.Accepted: |
73 if res == QDialog.DialogCode.Accepted: |
73 loginData = dlg.getData() |
74 loginData = dlg.getData() |
74 return (True, loginData[0], loginData[1], loginData[2]) |
75 return (True, loginData[0], loginData[1], loginData[2]) |
75 else: |
76 else: |
76 return (False, "", "", False) |
77 return (False, "", "", False) |
77 |
78 |
78 def _clientSslServerTrustPromptCallback(self, trust_dict): |
79 def _clientSslServerTrustPromptCallback(self, trust_dict): |
79 """ |
80 """ |
80 Protected method called by the client to request acceptance for a |
81 Protected method called by the client to request acceptance for a |
81 ssl server certificate. |
82 ssl server certificate. |
82 |
83 |
83 @param trust_dict dictionary containing the trust data |
84 @param trust_dict dictionary containing the trust data |
84 @return tuple of three values (retcode, acceptedFailures, save). |
85 @return tuple of three values (retcode, acceptedFailures, save). |
85 Retcode should be true, if the certificate should be accepted, |
86 Retcode should be true, if the certificate should be accepted, |
86 acceptedFailures should indicate the accepted certificate failures |
87 acceptedFailures should indicate the accepted certificate failures |
87 and save should be True, if subversion should save the certificate. |
88 and save should be True, if subversion should save the certificate. |
91 with EricOverridenCursor(): |
92 with EricOverridenCursor(): |
92 parent = isinstance(self, QWidget) and self or None |
93 parent = isinstance(self, QWidget) and self or None |
93 msgBox = EricMessageBox.EricMessageBox( |
94 msgBox = EricMessageBox.EricMessageBox( |
94 EricMessageBox.Question, |
95 EricMessageBox.Question, |
95 self.tr("Subversion SSL Server Certificate"), |
96 self.tr("Subversion SSL Server Certificate"), |
96 self.tr("""<p>Accept the following SSL certificate?</p>""" |
97 self.tr( |
97 """<table>""" |
98 """<p>Accept the following SSL certificate?</p>""" |
98 """<tr><td>Realm:</td><td>{0}</td></tr>""" |
99 """<table>""" |
99 """<tr><td>Hostname:</td><td>{1}</td></tr>""" |
100 """<tr><td>Realm:</td><td>{0}</td></tr>""" |
100 """<tr><td>Fingerprint:</td><td>{2}</td></tr>""" |
101 """<tr><td>Hostname:</td><td>{1}</td></tr>""" |
101 """<tr><td>Valid from:</td><td>{3}</td></tr>""" |
102 """<tr><td>Fingerprint:</td><td>{2}</td></tr>""" |
102 """<tr><td>Valid until:</td><td>{4}</td></tr>""" |
103 """<tr><td>Valid from:</td><td>{3}</td></tr>""" |
103 """<tr><td>Issuer name:</td><td>{5}</td></tr>""" |
104 """<tr><td>Valid until:</td><td>{4}</td></tr>""" |
104 """</table>""") |
105 """<tr><td>Issuer name:</td><td>{5}</td></tr>""" |
105 .format(trust_dict["realm"], |
106 """</table>""" |
106 trust_dict["hostname"], |
107 ).format( |
107 trust_dict["finger_print"], |
108 trust_dict["realm"], |
108 trust_dict["valid_from"], |
109 trust_dict["hostname"], |
109 trust_dict["valid_until"], |
110 trust_dict["finger_print"], |
110 trust_dict["issuer_dname"]), |
111 trust_dict["valid_from"], |
111 modal=True, parent=parent) |
112 trust_dict["valid_until"], |
112 permButton = msgBox.addButton(self.tr("&Permanent accept"), |
113 trust_dict["issuer_dname"], |
113 EricMessageBox.AcceptRole) |
114 ), |
114 tempButton = msgBox.addButton(self.tr("&Temporary accept"), |
115 modal=True, |
115 EricMessageBox.AcceptRole) |
116 parent=parent, |
|
117 ) |
|
118 permButton = msgBox.addButton( |
|
119 self.tr("&Permanent accept"), EricMessageBox.AcceptRole |
|
120 ) |
|
121 tempButton = msgBox.addButton( |
|
122 self.tr("&Temporary accept"), EricMessageBox.AcceptRole |
|
123 ) |
116 msgBox.addButton(self.tr("&Reject"), EricMessageBox.RejectRole) |
124 msgBox.addButton(self.tr("&Reject"), EricMessageBox.RejectRole) |
117 msgBox.exec() |
125 msgBox.exec() |
118 |
126 |
119 if msgBox.clickedButton() == permButton: |
127 if msgBox.clickedButton() == permButton: |
120 return (True, trust_dict["failures"], True) |
128 return (True, trust_dict["failures"], True) |
121 elif msgBox.clickedButton() == tempButton: |
129 elif msgBox.clickedButton() == tempButton: |
122 return (True, trust_dict["failures"], False) |
130 return (True, trust_dict["failures"], False) |
123 else: |
131 else: |
124 return (False, 0, False) |
132 return (False, 0, False) |
125 |
133 |
126 def _clientLogCallback(self): |
134 def _clientLogCallback(self): |
127 """ |
135 """ |
128 Protected method called by the client to request a log message. |
136 Protected method called by the client to request a log message. |
129 |
137 |
130 @return a flag indicating success and the log message (string) |
138 @return a flag indicating success and the log message (string) |
131 """ |
139 """ |
132 from .SvnCommitDialog import SvnCommitDialog |
140 from .SvnCommitDialog import SvnCommitDialog |
|
141 |
133 if self.logMessage: |
142 if self.logMessage: |
134 return True, self.logMessage |
143 return True, self.logMessage |
135 else: |
144 else: |
136 # call CommitDialog and get message from there |
145 # call CommitDialog and get message from there |
137 dlg = SvnCommitDialog(self) |
146 dlg = SvnCommitDialog(self) |