Skip to content

Commit

Permalink
apply gallery patch | not implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Logic-gate committed Feb 22, 2023
1 parent 2d794b3 commit 6cca6bf
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
19 changes: 19 additions & 0 deletions qml/pages/SettingsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Page {
property var currentIconSet
property var currentIcon
property var configBoolean
property var applyPatchBoolean

SilicaFlickable {
id: settingsContainer
Expand Down Expand Up @@ -41,6 +42,16 @@ Page {
}
}

TextSwitch {
id: applyPatch
text: qsTr("Add A Gallery Folder For Drive! Image Downloads")
description: qsTr("This will apply a patch to Jolla Gallery that will display an aditional Gallery folder for Drive!")
checked: false
// onCheckedChanged: {
// py.applyPatch(applyPatch.checked)
// }
}

TextSwitch {
id: gridModeSet
text: qsTr("Enable Grid Mode")
Expand Down Expand Up @@ -75,13 +86,21 @@ Page {
iconSet.checked = option
})

setHandler('applyPatchBoolean', function (option) {
applyPatch.checked = option
})

setHandler('currentConfig', function (option) {
currentIcon = option
})

importModule('main', function () {})
}

function applyPatch(checked) {
call('main.api.applyPatch', [checked], function () {})
}

function configBooleanIconChange(checked) {
call('main.api.configBooleanIconChange', [checked], function () {})
}
Expand Down
4 changes: 4 additions & 0 deletions qml/python/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
PORT = 8098
SUCCESS_MESSAGE = 'You can close this page now!...'
DEFAULT_CONFIG = "iconSet=[silicaIconSet]\npageSize=[25]"
PATCH_PATH = "/usr/share//harbour-cargo/qml/python/patches/"
JOLLA_GALLERY_PATH = '/usr/share/jolla-gallery/'
GALLERY_QML_256 = '7ed28197af82d58d0fb3d4599db9ba08b15556efde7f8e4c85ac91304671997e'
GALLERY_START_PAGE_256 = '83fac1158194a85917605d18fbb3a458677fb4e978615b3c4e85b097a0c79519'

SCOPES = [
'https://www.googleapis.com/auth/drive.metadata.readonly',
Expand Down
54 changes: 54 additions & 0 deletions qml/python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import header
import hashlib
import mimetypes
import hashlib


socket.setdefaulttimeout = 5
Expand Down Expand Up @@ -53,6 +54,14 @@ def __init__(self):
self.host = header.HOST
self.port = header.PORT
self.success_message = header.SUCCESS_MESSAGE
self.gallery_path = header.JOLLA_GALLERY_PATH
self.gallery_qml_256 = header.GALLERY_QML_256
self.gallery_start_page_256 = header.GALLERY_START_PAGE_256
self.gallery_name = 'gallery'
self.gallery_start_page_name = 'GalleryStartPage'
self.qml_suffix = '.qml'
self.patch_suffix = '.patch'
self.patch_path = header.PATCH_PATH

def pathChecks(self, path):

Expand Down Expand Up @@ -432,6 +441,51 @@ def isAscii(self, string):
else:
return True

def checkSum(self, filename):

with open(filename, 'rb') as orig:
bytes = orig.read()
sha256sum = hashlib.sha256(bytes).hexdigest()
return sha256sum

def patchCommand(self, file, patch):

patch_command = "patch -u -b %s -i %s" %(file, self.patch_path + patch + self.patch_suffix)
print(patch_command)
return os.system(patch_command)

def applyPatch(self, checked):
'''
apply patches/ to header.gallery_path
gallery.qml and pages/GalleryStartPage.qml
This will add a Cargo! Photos section to Gallery
will checksum both files as of 4.5.0.18
'''

gallery = self.gallery_path + self.gallery_name + self.qml_suffix
gallery_start_page = self.gallery_path + 'pages/' + self.gallery_start_page_name + self.qml_suffix

if checked:
print(checked, 'applyingPatch')
if self.checkSum(gallery) == self.gallery_qml_256 and self.checkSum(gallery_start_page) == self.gallery_start_page_256:
self.patchCommand(gallery, self.gallery_name)
self.patchCommand(gallery_start_page, self.gallery_start_page_name)
pyotherside.send('applyPatch', True)
return True
else:
pass

else:
print(checked, 'revertingPatch')
pyotherside.send('applyPatch', False)
# patchCommand(self.gallery_name)
# patchCommand(self.gallery_start_page_name)
return False




api = Operations()

0 comments on commit 6cca6bf

Please sign in to comment.