diff --git a/.gitignore b/.gitignore index 3d7cc77..92c6e69 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ dsa_priv.pem *.pyc .DS_Store *~ -Linux/build/ +Linux/dist +Windows/bungloo \ No newline at end of file diff --git a/Linux/deploy/Makefile.exmp b/Linux/Makefile.exmp similarity index 100% rename from Linux/deploy/Makefile.exmp rename to Linux/Makefile.exmp diff --git a/Linux/deploy/bungloo.desktop.exmp b/Linux/bungloo.desktop.exmp similarity index 100% rename from Linux/deploy/bungloo.desktop.exmp rename to Linux/bungloo.desktop.exmp diff --git a/Linux/deploy/debian/changelog b/Linux/debian/changelog similarity index 100% rename from Linux/deploy/debian/changelog rename to Linux/debian/changelog diff --git a/Linux/deploy/debian/compat b/Linux/debian/compat similarity index 100% rename from Linux/deploy/debian/compat rename to Linux/debian/compat diff --git a/Linux/deploy/debian/control b/Linux/debian/control similarity index 100% rename from Linux/deploy/debian/control rename to Linux/debian/control diff --git a/Linux/deploy/debian/copyright b/Linux/debian/copyright similarity index 100% rename from Linux/deploy/debian/copyright rename to Linux/debian/copyright diff --git a/Linux/deploy/debian/rules b/Linux/debian/rules similarity index 100% rename from Linux/deploy/debian/rules rename to Linux/debian/rules diff --git a/Linux/deploy/deploy.sh b/Linux/deploy.sh similarity index 87% rename from Linux/deploy/deploy.sh rename to Linux/deploy.sh index b902101..a60ebb8 100755 --- a/Linux/deploy/deploy.sh +++ b/Linux/deploy.sh @@ -2,8 +2,8 @@ VERSION="1.3.0" DEPLOYPATH="bungloo-${VERSION}" -LINUXPATH=".." -SHAREDPATH="../.." +QTPATH="../Qt" +SHAREDPATH=".." DISTPATH=dist rm -rf $DEPLOYPATH @@ -14,8 +14,8 @@ mkdir -p $DEPLOYPATH/bin mkdir -p $DEPLOYPATH/bungloo touch $DEPLOYPATH/bungloo/__init__.py -cp $LINUXPATH/Bungloo.py $DEPLOYPATH/bin/bungloo -cp $LINUXPATH/Helper.py $LINUXPATH/Windows.py $DEPLOYPATH/bungloo +cp $QTPATH/Bungloo.py $DEPLOYPATH/bin/bungloo +cp $QTPATH/Helper.py $QTPATH/Windows.py $DEPLOYPATH/bungloo cat setup.py.exmp | sed -e "s/{VERSION}/${VERSION}/g" > $DEPLOYPATH/setup.py cat Makefile.exmp | sed -e "s/{VERSION}/${VERSION}/g" > $DEPLOYPATH/Makefile cat bungloo.desktop.exmp | sed -e "s/{VERSION}/${VERSION}/g" > $DEPLOYPATH/bungloo.desktop diff --git a/Linux/deploy/setup.py.exmp b/Linux/setup.py.exmp similarity index 100% rename from Linux/deploy/setup.py.exmp rename to Linux/setup.py.exmp diff --git a/Linux/Bungloo.py b/Qt/Bungloo.py similarity index 94% rename from Linux/Bungloo.py rename to Qt/Bungloo.py index 3c357f8..72d04f2 100755 --- a/Linux/Bungloo.py +++ b/Qt/Bungloo.py @@ -1,11 +1,12 @@ #!/usr/bin/env python2 import os, sys, pickle, subprocess, shutil -from PyQt4 import QtCore, QtGui, QtWebKit +from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork -RUNNING_LOCAL = os.path.basename(__file__) == "Bungloo.py" +RUNNING_LOCAL = os.path.basename(sys.argv[0]) == "Bungloo.py" +RUNNING_ON_WINDOWS = os.name == "nt" -if RUNNING_LOCAL: +if RUNNING_LOCAL or RUNNING_ON_WINDOWS: import Windows, Helper else: from bungloo import Windows, Helper @@ -13,6 +14,11 @@ else: class Bungloo: def __init__(self): + + sslConfig = QtNetwork.QSslConfiguration.defaultConfiguration() + sslConfig.setProtocol(QtNetwork.QSsl.TlsV1) + QtNetwork.QSslConfiguration.setDefaultConfiguration(sslConfig) + self.app = QtGui.QApplication(sys.argv) self.new_message_windows = [] self.controller = Controller(self) @@ -30,7 +36,7 @@ class Bungloo: def resources_path(self): if RUNNING_LOCAL: - return os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) + return os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..')) else: return Helper.Helper.get_resource_path() diff --git a/Linux/Helper.py b/Qt/Helper.py similarity index 88% rename from Linux/Helper.py rename to Qt/Helper.py index ea8a36e..09cd069 100644 --- a/Linux/Helper.py +++ b/Qt/Helper.py @@ -2,17 +2,17 @@ from PyQt4 import QtCore, QtGui, QtWebKit from PyQt4.QtCore import QTimer, QVariant, SIGNAL from PyQt4.QtGui import * -from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply +from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply, QSslSocket from PyQt4.QtWebKit import QWebView -import os +import os, sys import array class Helper: - @classmethod - def get_resource_path(cls): - return os.path.dirname(__file__) + @classmethod + def get_resource_path(cls): + return os.path.dirname(sys.argv[0]) class WebPage(QtWebKit.QWebPage): def __init__(self, parent=0, app=None): @@ -43,6 +43,8 @@ class WebViewCreator(QtWebKit.QWebView): self.customContextMenuRequested.connect(self.context_menu_requested) self.actions = [] + self.page().networkAccessManager().sslErrors.connect(lambda reply, errors: self.handleSslErrors(reply, errors)) + def copy_link(): self.page().triggerAction(QtWebKit.QWebPage.CopyLinkToClipboard) self.action_copy_link = QtGui.QAction('Copy Lin&k', self, triggered=copy_link) @@ -85,7 +87,10 @@ class WebViewCreator(QtWebKit.QWebView): def load_finished(self, ok, callback=None): frame = self.page().mainFrame() if self.is_local: - frame.evaluateJavaScript("var OS_TYPE = 'linux';") + os_type = "linux" + if os.name == "nt": + os_type = "windows" + frame.evaluateJavaScript("var OS_TYPE = '" + os_type + "';") js_plugin_path = os.path.expanduser('~/.config/bungloo/Plugin.js') if os.access(js_plugin_path, os.R_OK): @@ -100,6 +105,12 @@ class WebViewCreator(QtWebKit.QWebView): if callback: callback(ok) + def handleSslErrors(self, reply, errors): + if os.name == "nt": # ignore SSL errors on Windows (yes a uggly workaround, don't know how to fix it yet) + for error in errors: + print error.errorString() + reply.ignoreSslErrors(errors) + class NetworkAccessManager(QNetworkAccessManager): @@ -113,6 +124,7 @@ class NetworkAccessManager(QNetworkAccessManager): self.setCookieJar(old_manager.cookieJar()) self.setProxy(old_manager.proxy()) self.setProxyFactory(old_manager.proxyFactory()) + self.sslErrors.connect(lambda reply, errors: old_manager.sslErrors) def createRequest(self, operation, request, data): if request.url().scheme() != "bungloo": diff --git a/Linux/Windows.py b/Qt/Windows.py similarity index 97% rename from Linux/Windows.py rename to Qt/Windows.py index 5fe85c3..1a1bfb3 100644 --- a/Linux/Windows.py +++ b/Qt/Windows.py @@ -1,5 +1,5 @@ from PyQt4 import QtCore, QtGui, QtWebKit -import Helper, urllib, urllib2 +import Helper, urllib, urllib2, os class Preferences: @@ -224,8 +224,10 @@ class Oauth: old_manager = self.auth_view.page().networkAccessManager() new_manager = Helper.NetworkAccessManager(old_manager, self.bungloo_callback) new_manager.authenticationRequired.connect(self.authentication_required) + new_manager.sslErrors.connect(lambda reply, errors: self.handleSslErrors(reply, errors)) self.auth_view.page().setNetworkAccessManager(new_manager) self.auth_view.show() + self.auth_view.load_url(url) return False @@ -250,6 +252,13 @@ class Oauth: if hasattr(self, "auth_view"): self.auth_view.hide() + def handleSslErrors(self, reply, errors): + if os.name == "nt": # ignore SSL errors on Windows (yes a uggly workaround, don't know how to fix it yet) + for error in errors: + print error.errorString() + reply.ignoreSslErrors(errors) + + class Login(QtGui.QDialog): def __init__(self): diff --git a/WebKit/scripts/helper/HostApp.js b/WebKit/scripts/helper/HostApp.js index 50bcbe8..8fa8b3a 100644 --- a/WebKit/scripts/helper/HostApp.js +++ b/WebKit/scripts/helper/HostApp.js @@ -129,7 +129,10 @@ define(function() { } HostApp.osType = function() { - return OS_TYPE == "mac" ? "OS X" : "Linux"; + var os_name = "OS X"; + if (OS_TYPE == "windows") os_name = "Windows"; + if (OS_TYPE == "linux") os_name = "Linux" + return os_name; } HostApp.notificateViewsAboutDeletedPost = function(postId, entity) { diff --git a/Windows/deploy.ps1 b/Windows/deploy.ps1 new file mode 100644 index 0000000..8441559 --- /dev/null +++ b/Windows/deploy.ps1 @@ -0,0 +1,12 @@ + +mkdir bungloo +Copy-Item ../Qt/* bungloo -Recurse +Copy-Item ../WebKit bungloo -Recurse +Copy-Item ../images bungloo -Recurse +Copy-Item setup.py bungloo +touch bungloo/__init__.py +Copy-Item msvcp90.dll bungloo +cd bungloo +python setup.py py2exe +cd .. +rm bungloo \ No newline at end of file diff --git a/Windows/installer.iss b/Windows/installer.iss new file mode 100644 index 0000000..4965a11 --- /dev/null +++ b/Windows/installer.iss @@ -0,0 +1,55 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "Bungloo" +#define MyAppVersion "1.3.0" +#define MyAppPublisher "Jabs Nu" +#define MyAppURL "http://jabs.nu/bungloo" +#define MyAppExeName "Bungloo.exe" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{5E44EE00-8ECE-40C8-AF6F-70397DD1DBFE} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={pf}\{#MyAppName} +DefaultGroupName={#MyAppName} +AllowNoIcons=yes +LicenseFile=C:\Users\Jeena\Documents\GitHub\Bungloo\LICENCE.txt +OutputBaseFilename=setup +SetupIconFile=C:\Users\Jeena\Documents\GitHub\Bungloo\images\Icon.ico +Compression=lzma +SolidCompression=yes + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked +Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 + +[Files] +Source: "C:\Users\Jeena\Documents\GitHub\Bungloo\Windows\bungloo\dist\Bungloo.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "C:\Users\Jeena\Documents\GitHub\Bungloo\Windows\bungloo\dist\library.zip"; DestDir: "{app}"; Flags: ignoreversion +Source: "C:\Users\Jeena\Documents\GitHub\Bungloo\Windows\bungloo\dist\python27.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "C:\Users\Jeena\Documents\GitHub\Bungloo\Windows\bungloo\dist\w9xpopen.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "C:\Users\Jeena\Documents\GitHub\Bungloo\Windows\bungloo\dist\images\*"; DestDir: "{app}\images"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "C:\Users\Jeena\Documents\GitHub\Bungloo\Windows\bungloo\dist\WebKit\*"; DestDir: "{app}\WebKit"; Flags: ignoreversion recursesubdirs createallsubdirs +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" +Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" +Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon +Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon + +[Run] +Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent + diff --git a/Windows/msvcp90.dll b/Windows/msvcp90.dll new file mode 100644 index 0000000..af6cc3d Binary files /dev/null and b/Windows/msvcp90.dll differ diff --git a/Windows/setup.py b/Windows/setup.py new file mode 100644 index 0000000..0ea0ceb --- /dev/null +++ b/Windows/setup.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python2 + +import os +from distutils.core import setup +import py2exe + +files = [] +for dirname, dirnames, filenames in os.walk('WebKit'): + for filename in filenames: + files += [(dirname, [os.path.join(dirname, filename)])] + +for dirname, dirnames, filenames in os.walk('images'): + for filename in filenames: + files += [(dirname, [os.path.join(dirname, filename)])] + +setup( + name = "Bungloo", + version = "1.3.0", + author = "Jeena Paradies", + author_email = "spam@jeenaparadies.net", + url = "http://jabs.nu/bungloo", + license = "BSD license", + data_files = files, + windows = ["Bungloo.py"], + options = { + "py2exe": { + "includes": ["sip", "ssl", "PyQt4.QtCore", "PyQt4.QtGui", "PyQt4.QtNetwork"], + "bundle_files": 2 + } + } + ) diff --git a/images/Icon.ico b/images/Icon.ico new file mode 100644 index 0000000..e386d9e Binary files /dev/null and b/images/Icon.ico differ diff --git a/images/Icon16.png b/images/Icon16.png new file mode 100644 index 0000000..765b5c8 Binary files /dev/null and b/images/Icon16.png differ diff --git a/images/Icon248.png b/images/Icon248.png new file mode 100644 index 0000000..83d5450 Binary files /dev/null and b/images/Icon248.png differ diff --git a/images/Icon32.png b/images/Icon32.png new file mode 100644 index 0000000..fed9bfc Binary files /dev/null and b/images/Icon32.png differ diff --git a/images/Icon48.png b/images/Icon48.png new file mode 100644 index 0000000..71dbc57 Binary files /dev/null and b/images/Icon48.png differ