Commit c1a779ef authored by Tijmen de Mes's avatar Tijmen de Mes

Added dialog for key generation

parent 8ed86a4e
...@@ -39,6 +39,82 @@ from blink.util import run_in_gui_thread ...@@ -39,6 +39,82 @@ from blink.util import run_in_gui_thread
__all__ = ['MessageManager', 'BlinkMessage'] __all__ = ['MessageManager', 'BlinkMessage']
ui_class, base_class = uic.loadUiType(Resources.get('generate_pgp_key_dialog.ui'))
class GeneratePGPKeyDialog(IncomingDialogBase, ui_class):
def __init__(self, parent=None):
super(GeneratePGPKeyDialog, self).__init__(parent)
self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)
self.setAttribute(Qt.WA_DeleteOnClose)
with Resources.directory:
self.setupUi(self)
self.slot = None
self.generate_button = self.dialog_button_box.addButton("Generate", QDialogButtonBox.AcceptRole)
self.generate_button.setIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton))
def show(self, activate=True):
self.setAttribute(Qt.WA_ShowWithoutActivating, not activate)
super(GeneratePGPKeyDialog, self).show()
class GeneratePGPKeyRequest(QObject):
finished = pyqtSignal(object)
accepted = pyqtSignal(object, str)
rejected = pyqtSignal(object)
sip_prefix_re = re.compile('^sips?:')
priority = 0
def __init__(self, dialog, account, scenario=0, session=None):
super(GeneratePGPKeyRequest, self).__init__()
self.account = account
self.dialog = dialog
self.session = session
self.dialog.finished.connect(self._SH_DialogFinished)
uri = self.sip_prefix_re.sub('', str(account.uri))
replaced1 = self.dialog.key_maybe_present_label.text().replace('ACCOUNT', uri)
replaced2 = self.dialog.key_present_label.text().replace('ACCOUNT', uri)
self.dialog.key_maybe_present_label.setText(replaced1)
self.dialog.key_present_label.setText(replaced2)
if scenario == 1:
self.dialog.key_maybe_present_label.show()
self.dialog.key_present_label.hide()
else:
self.dialog.key_maybe_present_label.hide()
self.dialog.key_present_label.show()
def __eq__(self, other):
return self is other
def __ne__(self, other):
return self is not other
def __lt__(self, other):
return self.priority < other.priority
def __le__(self, other):
return self.priority <= other.priority
def __gt__(self, other):
return self.priority > other.priority
def __ge__(self, other):
return self.priority >= other.priority
def _SH_DialogFinished(self, result):
self.finished.emit(self)
if result == QDialog.Accepted:
self.accepted.emit(self)
elif result == QDialog.Rejected:
self.rejected.emit(self)
del ui_class, base_class
ui_class, base_class = uic.loadUiType(Resources.get('import_private_key_dialog.ui')) ui_class, base_class = uic.loadUiType(Resources.get('import_private_key_dialog.ui'))
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>768</width>
<height>280</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>640</width>
<height>280</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>334</height>
</size>
</property>
<property name="windowTitle">
<string>Generate/Import PGP keys</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>icons/work/lock.svg</pixmap>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Generate/Import PGP Keys</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="key_present_label">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;You received an encrypted message for &lt;span style=&quot; font-weight:600;&quot;&gt;ACCOUNT&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;To use end-to-end encryption for messaging you need PGP keys for this account and no key is currently present.&lt;/p&gt;&lt;p&gt;Please choose &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;'Export private key'&lt;/span&gt; on a device/browser where you signed in before with Blink or Sylk.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="key_maybe_present_label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;To use end-to-end encryption for messaging you need PGP keys for &lt;span style=&quot; font-weight:600;&quot;&gt;ACCOUNT&lt;/span&gt;.&lt;br/&gt;No key is currently present.&lt;/p&gt;&lt;p&gt;If you used Blink or Sylk on a device/browser before with end-to-end encryption enabled you need to choose &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;'Export private key'&lt;/span&gt; there.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If you &lt;span style=&quot; font-weight:600;&quot;&gt;lost access&lt;/span&gt; to this device/browser, please continue with 'Generate'. 'Cancel' will &lt;span style=&quot; font-weight:600;&quot;&gt;disable&lt;/span&gt; end-to-end encrypted messaging &lt;span style=&quot; font-weight:600;&quot;&gt;for this session&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;If you generate a new key, your previous messages &lt;span style=&quot; font-weight:600;&quot;&gt;cannot&lt;/span&gt; be read on newer devices.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QDialogButtonBox" name="dialog_button_box">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>dialog_button_box</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>dialog_button_box</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment