From 60b4b077d80b14ad353c5bc283b9907892aac0d0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 7 Apr 2018 11:35:48 +0100 Subject: [PATCH] Show onion email address as QR code on user control panel --- src/freedombone-controlpanel-user | 52 ++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/src/freedombone-controlpanel-user b/src/freedombone-controlpanel-user index 2052997e..d8045536 100755 --- a/src/freedombone-controlpanel-user +++ b/src/freedombone-controlpanel-user @@ -856,28 +856,50 @@ function show_your_email_address { if [ -f "$HOME/.email_onion_domain" ]; then onion_domain=$(cat "$HOME/.email_onion_domain") fi + dialog_height=14 if [[ "$HOSTNAME" != *'.onion' && "$onion_domain" ]]; then - msgstr=$"Email Address: $MY_EMAIL_ADDRESS\\n\\nOnion Email: ${USER}@${onion_domain}\\n\\nKey ID: $GPG_ID\\n\\nFingerprint: $GPG_FINGERPRINT\\n\\nCreated: $GPG_DATE" + if [ ! -f ~/.mutt/bdsmail ]; then + msgstr=$"\\nYou can press SHIFT and then drag the mouse and right click to copy.\\n\\nEmail Address: $MY_EMAIL_ADDRESS\\n\\nOnion Email: ${USER}@${onion_domain}\\n\\nKey ID: $GPG_ID\\n\\nFingerprint: $GPG_FINGERPRINT\\n\\nCreated: $GPG_DATE" + dialog_height=17 + else + bdsmail_address=$(grep 'set from=' ~/.mutt/bdsmail | awk -F '=' '{print $2}') + msgstr=$"\\nYou can press SHIFT and then drag the mouse and right click to copy.\\n\\nEmail Address: $MY_EMAIL_ADDRESS\\n\\nOnion Email: ${USER}@${onion_domain}\\n\\nKey ID: $GPG_ID\\n\\nFingerprint: $GPG_FINGERPRINT\\n\\nCreated: $GPG_DATE\\n\\nI2P Address: ${bdsmail_address}" + dialog_height=20 + fi else - msgstr=$"Email Address: $MY_EMAIL_ADDRESS\\n\\nKey ID: $GPG_ID\\n\\nFingerprint: $GPG_FINGERPRINT\\n\\nCreated: $GPG_DATE" + if [ ! -f ~/.mutt/bdsmail ]; then + msgstr=$"\\nYou can press SHIFT and then drag the mouse and right click to copy.\\n\\nEmail Address: $MY_EMAIL_ADDRESS\\n\\nKey ID: $GPG_ID\\n\\nFingerprint: $GPG_FINGERPRINT\\n\\nCreated: $GPG_DATE" + dialog_height=14 + else + bdsmail_address=$(grep 'set from=' ~/.mutt/bdsmail | awk -F '=' '{print $2}') + msgstr=$"\\nYou can press SHIFT and then drag the mouse and right click to copy.\\n\\nEmail Address: $MY_EMAIL_ADDRESS\\n\\nKey ID: $GPG_ID\\n\\nFingerprint: $GPG_FINGERPRINT\\n\\nCreated: $GPG_DATE\\n\\nI2P Address: ${bdsmail_address}" + dialog_height=17 + fi fi - if [ ! -f ~/.mutt/bdsmail ]; then - dialog --title $"Show your Email Address" \ - --backtitle $"Freedombone User Control Panel" \ - --msgbox "$msgstr" 14 100 - else - bdsmail_address=$(grep 'set from=' ~/.mutt/bdsmail | awk -F '=' '{print $2}') - dialog --title $"Show your Email Address" \ - --backtitle $"Freedombone User Control Panel" \ - --msgbox $"\\nYou can press SHIFT and then drag the mouse and right click to copy.\\n\\nEmail Address: $MY_EMAIL_ADDRESS\\n\\nKey ID: $GPG_ID\\n\\nFingerprint: $GPG_FINGERPRINT\\n\\nCreated: $GPG_DATE\\n\\nI2P Address: ${bdsmail_address}" 17 100 - clear + + dialog --title $"Show your Email Address" \ + --backtitle $"Freedombone User Control Panel" \ + --msgbox "$msgstr" $dialog_height 100 + + clear + qr_code_shown= + if [ "$onion_domain" ]; then echo '' - echo $'Your bdsmail address as a QR code' + echo $'Your onion email address:' + echo '' + echo -n "${USER}@${onion_domain}" | qrencode -t UTF8 + echo '' + qr_code_shown=1 + fi + if [ -f ~/.mutt/bdsmail ]; then + echo '' + echo $'Your bdsmail address:' echo '' echo -n "${bdsmail_address}" | qrencode -t UTF8 echo '' - echo "${bdsmail_address}" - echo '' + qr_code_shown=1 + fi + if [ $qr_code_shown ]; then any_key fi }