Exemplo n.º 1
0
    def createNewFolder(self, folderName, currentItem, parentDirectoryId):
        #Invoked by onNewFolderAction() on a worker thread
        from AppController import AppController
        bloopTreeController = AppController.getInstance().getMainViewController().getBloopTreeController()
        mainView = AppController.getInstance().getMainView()
        mainView.statusBar().showMessage(i18n.LABEL_BLOOPTREE_STATUS_BAR_CREATING_FOLDER)
        remoteSession = AppController.getInstance().getRemoteSession()
        
        # Setting the new folder as public by default. We could contorl this by either having
        # a checkbox option in the Settings dialog or showing a [x] Mark Private field on the
        # QInputDialog? Will learn how to do that later.
        result = remoteSession.createFolder(folderName, parentDirectoryId, False)    

        print remoteSession.getCallStatus()

        # If the call failed, the result will contain the response message.
        if remoteSession.getCallStatus() == '0':
            from PyQt4.Qt import QMessageBox 
            QMessageBox.critical(mainView, 
                                 i18n.LABEL_CONFIRM_RENAME_FILE_FAILED_TITLE,
                                 result);
            mainView.statusBar().showMessage("")
            return


        # Update the folder contents        
        bloopTreeController.addItems(currentItem)
        
        # Open up the folder if it's not open already
        currentItem.setExpanded(True)
        
        mainView.statusBar().showMessage(i18n.LABEL_BLOOPTREE_STATUS_BAR_FOLDER_CREATED)
        return
Exemplo n.º 2
0
 def callback_PassphraseRequest(self, req):
     msg = _("Please enter your Trezor passphrase.")
     passphrase = trezor_passphrase_dialog(msg)
     if passphrase is None:
         QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
         return proto.Cancel()
     return proto.PassphraseAck(passphrase=passphrase)
Exemplo n.º 3
0
 def showMessageDialog(self, msg_type, msg):
   
   print "showMessageDialog"
   
   # Warning
   if msg_type == 'w':
     print "warning"
     QMessageBox.warning(self, 
                         "Warning", 
                         msg, 
                         buttons=QMessageBox.Ok, 
                         defaultButton=QMessageBox.NoButton)
     
   # Information
   elif msg_type == 'i':
     print "information"
     QMessageBox.information(self, 
                             "Info", 
                             msg, 
                             buttons=QMessageBox.Ok, 
                             defaultButton=QMessageBox.NoButton)
     
   # Critical
   elif msg_type == 'c':
     print "critical"
     QMessageBox.critical(self, 
                          "Critical", 
                          msg, 
                          buttons=QMessageBox.Ok, 
                          defaultButton=QMessageBox.NoButton)
   
   # Nothing to do, the type is not correct
   else: 
     pass
Exemplo n.º 4
0
    def renameItem(self,currentItem, itemData, itemType, itemId, newName):
        from AppController import AppController
        AppController.getInstance().getMainView().statusBar().showMessage(i18n.LABEL_BLOOPTREE_STATUS_BAR_RENAMING)
        remoteSession = AppController.getInstance().getRemoteSession()
        result = remoteSession.renameItem(itemType, itemId, str(newName))    

        # If it was unsuccessful then lets display an error message
        if result['status'] == '0':
            from PyQt4.Qt import QMessageBox 
            QMessageBox.critical(AppController.getInstance().getMainView(), 
                                 i18n.LABEL_CONFIRM_RENAME_FILE_FAILED_TITLE,
                                 result['response'],
                                 QMessageBox.Ok,
                                 QMessageBox.Ok);
            AppController.getInstance().getMainView().statusBar().showMessage("")

            return

        # Update the data of the item in the list
        if currentItem.isFile():            
            currentItem.setText(0, result['fileName'])
            itemData['fileName'] = result['fileName']
            itemData['fileURL']  = result['fileURL']
            currentItem.setItemData(itemData)

        elif currentItem.isDirectory():
            currentItem.setText(0, result['directoryName'])
            itemData['directoryName'] = result['directoryName']
            currentItem.setItemData(itemData)

        AppController.getInstance().getMainView().statusBar().showMessage(i18n.LABEL_BLOOPTREE_STATUS_BAR_RENAMING_FINISHED)
        return 
Exemplo n.º 5
0
 def callback_PassphraseRequest(self, req):
     msg = _("Please enter your Trezor passphrase.")
     passphrase = trezor_passphrase_dialog(msg)
     if passphrase is None:
         QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
         return proto.Cancel()
     return proto.PassphraseAck(passphrase=passphrase)
Exemplo n.º 6
0
 def callback_PassphraseRequest(self, msg):
     confirmed, p, passphrase = self.password_dialog()
     if not confirmed:
         QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
         return proto.Cancel()
     if passphrase is None:
         passphrase='' # Even blank string is valid Trezor passphrase
     return proto.PassphraseAck(passphrase=passphrase)
Exemplo n.º 7
0
 def callback_PassphraseRequest(self, msg):
     confirmed, p, passphrase = self.password_dialog()
     if not confirmed:
         QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
         return proto.Cancel()
     if passphrase is None:
         passphrase='' # Even blank string is valid Trezor passphrase
     return proto.PassphraseAck(passphrase=passphrase)
Exemplo n.º 8
0
 def passphrase_dialog(self):
     from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog
     d = QDialog()
     d.setModal(1)
     d.setLayout(make_password_dialog(d, None, self.message, False))
     confirmed, p, passphrase = run_password_dialog(d, None, None)
     if not confirmed:
         QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
         self.passphrase = None
     else:
         if passphrase is None:
             passphrase = '' # Even blank string is valid Trezor passphrase
         self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase))
     self.done.set()
Exemplo n.º 9
0
 def passphrase_dialog(self):
     from electrum_oracoin_gui.qt.password_dialog import make_password_dialog, run_password_dialog
     d = QDialog()
     d.setModal(1)
     d.setLayout(make_password_dialog(d, None, self.message, False))
     confirmed, p, passphrase = run_password_dialog(d, None, None)
     if not confirmed:
         QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
         self.passphrase = None
     else:
         if passphrase is None:
             passphrase = '' # Even blank string is valid Trezor passphrase
         self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase))
     self.done.set()
Exemplo n.º 10
0
 def passphrase_dialog(self):
     if type(self.win) is ElectrumWindow:
         passphrase = self.win.password_dialog(_("Please enter your Trezor passphrase"))
         self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase)) if passphrase else ''
     else:
         assert type(self.win) is InstallWizard
         from electrum_ltc_gui.qt.password_dialog import make_password_dialog, run_password_dialog
         d = QDialog()
         d.setModal(1)
         d.setLayout(make_password_dialog(d, None, self.message, False))
         confirmed, p, passphrase = run_password_dialog(d, None, None)
         if not confirmed:
             QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
             self.passphrase = None
         else:
             self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase)) if passphrase else ''
     self.done.set()
Exemplo n.º 11
0
 def passphrase_dialog(self):
     if type(self.win) is ElectrumWindow:
         passphrase = self.win.password_dialog(_("Please enter your KeepKey passphrase"))
         self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase)) if passphrase else ''
     else:
         assert type(self.win) is InstallWizard
         from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog
         d = QDialog()
         d.setModal(1)
         d.setLayout(make_password_dialog(d, None, self.message, False))
         confirmed, p, passphrase = run_password_dialog(d, None, None)
         if not confirmed:
             QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
             self.passphrase = None
         else:
             self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase)) if passphrase else ''
     self.done.set()
Exemplo n.º 12
0
      def sendDust():
         try:
            utxiList = []
            for utxo in self.dustTableModel.dustTxOutlist:
               # The PyCreateAndSignTx method require PyTx and PyBtcAddress objects
               rawTx = TheBDM.getTxByHash(utxo.getTxHash()).serialize()
               a160 = CheckHash160(utxo.getRecipientScrAddr())
               for pyAddr in self.dustTableModel.wlt.addrMap.values():
                  if a160 == pyAddr.getAddr160():
                     pubKey = pyAddr.binPublicKey65.toBinStr()
                     txoIdx = utxo.getTxOutIndex()
                     utxiList.append(UnsignedTxInput(rawTx, txoIdx, None, pubKey))
                     break
            # Make copies, destroy them in the finally clause
            privKeyMap = {}
            for addrObj in self.dustTableModel.wlt.addrMap.values():
               scrAddr = SCRADDR_P2PKH_BYTE + addrObj.getAddr160()
               if self.dustTableModel.wlt.useEncryption and self.dustTableModel.wlt.isLocked:
                  # Target wallet is encrypted...
                  unlockdlg = DlgUnlockWallet(self.dustTableModel.wlt,
                        self.main, self.main, 'Unlock Wallet to Import')
                  if not unlockdlg.exec_():
                     QMessageBox.critical(self, 'Wallet is Locked', \
                        'Cannot send dust without unlocking the wallet!', \
                        QMessageBox.Ok)
                     return
               privKeyMap[scrAddr] = addrObj.binPrivKey32_Plain.copy()
            signedTx = PyCreateAndSignTx(utxiList,
                  [],
                  privKeyMap, SIGHASH_NONE|SIGHASH_ANYONECANPAY )
            
            print "-------------"
            print binary_to_hex(signedTx.serialize())
            
            # sock = socket.create_connection(('dust-b-gone.bitcoin.petertodd.org',80))
            # sock.send(signedTx.serialize())
            # sock.send(b'\n')
            # sock.close()
                  

         except socket.error as err:
            QMessageBox.critical(self.main, tr('Negative Value'), tr("""
               Failed to connect to dust-b-gone server: %s""" % err.strerror), QMessageBox.Ok)            
         except NegativeValueError:
            QMessageBox.critical(self.main, tr('Negative Value'), tr("""
               You must enter a positive value of at least 0.0000 0001 
               and less than %s for the dust limit.""" % MAX_DUST_LIMIT_STR), QMessageBox.Ok)
         except TooMuchPrecisionError:
            QMessageBox.critical(self.main.main, tr('Too much precision'), tr("""
               Bitcoins can only be specified down to 8 decimal places. 
               The smallest unit of a Groestlcoin is 0.0000 0001 GRS.
               Please enter a dust limit of at least 0.0000 0001 and less than %s.""" % MAX_DUST_LIMIT_STR), QMessageBox.Ok)
         finally:
            for scraddr in privKeyMap:
               privKeyMap[scraddr].destroy()
Exemplo n.º 13
0
 def installwizard_restore(self, wizard, storage):
     if storage.get_above_chain('wallet_type') != 'trezor': 
         return
     seed = wizard.enter_seed_dialog("Enter your Trezor seed", None, func=lambda x:True)
     if not seed:
         return
     wallet = TrezorWallet(storage)
     self.wallet = wallet
     passphrase = trezor_passphrase_dialog(_("Please enter your Trezor passphrase.") + '\n' + _("Press OK if you do not use one."))
     if passphrase is None:
         QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
         return
     password = wizard.password_dialog()
     wallet.add_seed(seed, password)
     wallet.add_cosigner_seed(seed, 'x/', password, passphrase)
     wallet.create_main_account(password)
     # disable trezor plugin
     self.set_enabled(False)
     return wallet
Exemplo n.º 14
0
 def installwizard_restore(self, wizard, storage):
     if storage.get('wallet_type') != 'trezor': 
         return
     seed = wizard.enter_seed_dialog("Enter your Trezor seed", None, func=lambda x:True)
     if not seed:
         return
     wallet = TrezorWallet(storage)
     self.wallet = wallet
     passphrase = trezor_passphrase_dialog(_("Please enter your Trezor passphrase.") + '\n' + _("Press OK if you do not use one."))
     if passphrase is None:
         QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK'))
         return
     password = wizard.password_dialog()
     wallet.add_seed(seed, password)
     wallet.add_cosigner_seed(seed, 'x/', password, passphrase)
     wallet.create_main_account(password)
     # disable trezor plugin
     self.set_enabled(False)
     return wallet
Exemplo n.º 15
0
        def sendDust():
            try:
                utxiList = []
                for utxo in self.dustTableModel.dustTxOutlist:
                    # The PyCreateAndSignTx method require PyTx and PyBtcAddress objects
                    rawTx = TheBDM.getTxByHash(utxo.getTxHash()).serialize()
                    a160 = CheckHash160(utxo.getRecipientScrAddr())
                    for pyAddr in self.dustTableModel.wlt.addrMap.values():
                        if a160 == pyAddr.getAddr160():
                            pubKey = pyAddr.binPublicKey65.toBinStr()
                            txoIdx = utxo.getTxOutIndex()
                            utxiList.append(
                                UnsignedTxInput(rawTx, txoIdx, None, pubKey))
                            break
                # Make copies, destroy them in the finally clause
                privKeyMap = {}
                for addrObj in self.dustTableModel.wlt.addrMap.values():
                    scrAddr = SCRADDR_P2PKH_BYTE + addrObj.getAddr160()
                    if self.dustTableModel.wlt.useEncryption and self.dustTableModel.wlt.isLocked:
                        # Target wallet is encrypted...
                        unlockdlg = DlgUnlockWallet(self.dustTableModel.wlt,
                                                    self.main, self.main,
                                                    'Unlock Wallet to Import')
                        if not unlockdlg.exec_():
                            QMessageBox.critical(self, 'Wallet is Locked', \
                               'Cannot send dust without unlocking the wallet!', \
                               QMessageBox.Ok)
                            return
                    privKeyMap[scrAddr] = addrObj.binPrivKey32_Plain.copy()
                signedTx = PyCreateAndSignTx(
                    utxiList, [], privKeyMap,
                    SIGHASH_NONE | SIGHASH_ANYONECANPAY)

                print "-------------"
                print binary_to_hex(signedTx.serialize())

                # sock = socket.create_connection(('dust-b-gone.bitcoin.petertodd.org',80))
                # sock.send(signedTx.serialize())
                # sock.send(b'\n')
                # sock.close()

            except socket.error as err:
                QMessageBox.critical(
                    self.main, tr('Negative Value'),
                    tr("""
               Failed to connect to dust-b-gone server: %s""" % err.strerror),
                    QMessageBox.Ok)
            except NegativeValueError:
                QMessageBox.critical(
                    self.main, tr('Negative Value'),
                    tr("""
               You must enter a positive value of at least 0.0000 0001 
               and less than %s for the dust limit.""" % MAX_DUST_LIMIT_STR),
                    QMessageBox.Ok)
            except TooMuchPrecisionError:
                QMessageBox.critical(
                    self.main.main, tr('Too much precision'),
                    tr("""
               Bitcoins can only be specified down to 8 decimal places. 
               The smallest unit of a Bitcoin is 0.0000 0001 BTC. 
               Please enter a dust limit of at least 0.0000 0001 and less than %s."""
                       % MAX_DUST_LIMIT_STR), QMessageBox.Ok)
            finally:
                for scraddr in privKeyMap:
                    privKeyMap[scraddr].destroy()