Skip to content

Commit

Permalink
Fixes for B&N key generation and Macs with bonded ethernet ports
Browse files Browse the repository at this point in the history
  • Loading branch information
apprenticeharper committed Apr 25, 2016
1 parent eaa7a1a commit 3a931df
Show file tree
Hide file tree
Showing 12 changed files with 1,045 additions and 2,016 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@
# 6.3.6 - Fixes for ADE ePub and PDF introduced in 6.3.5
# 6.4.0 - Updated for new Kindle for PC encryption
# 6.4.1 - Fix for some new tags in Topaz ebooks.
# 6.4.2 - Fix for more new tags in Topaz ebooks and very small Topaz ebooks
# 6.4.3 - Fix for error that only appears when not in debug mode
# Also includes fix for Macs with bonded ethernet ports


"""
Decrypt DRMed ebooks.
"""

PLUGIN_NAME = u"DeDRM"
PLUGIN_VERSION_TUPLE = (6, 4, 1)
PLUGIN_VERSION_TUPLE = (6, 4, 3)
PLUGIN_VERSION = u".".join([unicode(str(x)) for x in PLUGIN_VERSION_TUPLE])
# Include an html helpfile in the plugin's zipfile with the following name.
RESOURCE_NAME = PLUGIN_NAME + '_Help.htm'
Expand Down Expand Up @@ -87,8 +90,12 @@ def __init__(self, stream):
def write(self, data):
if isinstance(data,unicode):
data = data.encode(self.encoding,"replace")
self.stream.write(data)
self.stream.flush()
try:
self.stream.write(data)
self.stream.flush()
except:
# We can do nothing if a write fails
pass
def __getattr__(self, attr):
return getattr(self.stream, attr)

Expand Down
28 changes: 26 additions & 2 deletions DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,19 @@ def __init__(self, parent=None,):
data_group_box_layout.addWidget(ccn_disclaimer_label)
layout.addSpacing(10)

key_group = QHBoxLayout()
data_group_box_layout.addLayout(key_group)
key_group.addWidget(QLabel(u"Retrieved key:", self))
self.key_display = QLabel(u"", self)
self.key_display.setToolTip(_(u"Click the Retrieve Key button to fetch your B&N encryption key from the B&N servers"))
key_group.addWidget(self.key_display)
self.retrieve_button = QtGui.QPushButton(self)
self.retrieve_button.setToolTip(_(u"Click to retrieve your B&N encryption key from the B&N servers"))
self.retrieve_button.setText(u"Retrieve Key")
self.retrieve_button.clicked.connect(self.retrieve_key)
key_group.addWidget(self.retrieve_button)
layout.addSpacing(10)

self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
Expand All @@ -579,8 +592,7 @@ def key_name(self):

@property
def key_value(self):
from calibre_plugins.dedrm.ignoblekeyfetch import fetch_key as fetch_bandn_key
return fetch_bandn_key(self.user_name,self.cc_number)
return unicode(self.key_display.text()).strip()

@property
def user_name(self):
Expand All @@ -590,6 +602,14 @@ def user_name(self):
def cc_number(self):
return unicode(self.cc_ledit.text()).strip()

def retrieve_key(self):
from calibre_plugins.dedrm.ignoblekeyfetch import fetch_key as fetch_bandn_key
fetched_key = fetch_bandn_key(self.user_name,self.cc_number)
if fetched_key == "":
errmsg = u"Could not retrieve key. Check username, password and intenet connectivity and try again."
error_dialog(None, "{0} {1}".format(PLUGIN_NAME, PLUGIN_VERSION), errmsg, show=True, show_copy_button=False)
else:
self.key_display.setText(fetched_key)

def accept(self):
if len(self.key_name) == 0 or len(self.user_name) == 0 or len(self.cc_number) == 0 or self.key_name.isspace() or self.user_name.isspace() or self.cc_number.isspace():
Expand All @@ -598,6 +618,10 @@ def accept(self):
if len(self.key_name) < 4:
errmsg = u"Key name must be at <i>least</i> 4 characters long!"
return error_dialog(None, "{0} {1}".format(PLUGIN_NAME, PLUGIN_VERSION), errmsg, show=True, show_copy_button=False)
if len(self.key_value) == 0:
self.retrieve_key()
if len(self.key_value) == 0:
return
QDialog.accept(self)

class AddEReaderDialog(QDialog):
Expand Down
Loading

0 comments on commit 3a931df

Please sign in to comment.