summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/tinycbor/.gitignore
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2025-07-02 11:05:27 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2025-07-17 08:11:25 +0000
commit910523718a9828423c77ab1344dbd6dc242d8a3a (patch)
treed6b35a31836ce0cc6cc5f509cbdaa736f55743bc /src/3rdparty/tinycbor/.gitignore
parent95139b2b06326dfe66cc4bd7e76d4f3b8400e1e9 (diff)
wasm: Handle multiple mime types in the clipboard
Create a single ClipboardItem with several mime types instead of multiple ClipboardItems (multiple clipboard items are allowed by the API, but generally not supported by the browsers) Support the web standard mime types for now: text/plain, text/html, and image/png. Adding extra mime types (e.g. text/markdown) may cause the browser to reject the ClipboardItem. Later, we can add support for testing if additional mime types are supported. Done-with: Even Oscar Andersen <even.oscar.andersen@qt.io> Done-with: Volker Hemsen Fixes: QTBUG-138044 Fixes: QTBUG-125366 Change-Id: I6adbf239597576e393da824232c5933e76ad851f Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Lorn Potter <lorn.potter@qt.io> (cherry picked from commit 1b24cfdac501bae99cc1e34a995ab78d18badd92) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/3rdparty/tinycbor/.gitignore')
0 files changed, 0 insertions, 0 deletions
='n121' href='#n121'>121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
#############################################################################
#
# Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
# Contact: http://www.qt-project.org/legal
#
# This file is part of the QtWebEngine module of the Qt Toolkit.
#
# $QT_BEGIN_LICENSE:LGPL$
# Commercial License Usage
# Licensees holding valid commercial Qt licenses may use this file in
# accordance with the commercial license agreement provided with the
# Software or, alternatively, in accordance with the terms contained in
# a written agreement between you and Digia.  For licensing terms and
# conditions see http://qt.digia.com/licensing.  For further information
# use the contact form at http://qt.digia.com/contact-us.
#
# GNU Lesser General Public License Usage
# Alternatively, this file may be used under the terms of the GNU Lesser
# General Public License version 2.1 as published by the Free Software
# Foundation and appearing in the file LICENSE.LGPL included in the
# packaging of this file.  Please review the following information to
# ensure the GNU Lesser General Public License version 2.1 requirements
# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#
# In addition, as a special exception, Digia gives you certain additional
# rights.  These rights are described in the Digia Qt LGPL Exception
# version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
#
# GNU General Public License Usage
# Alternatively, this file may be used under the terms of the GNU
# General Public License version 3.0 as published by the Free Software
# Foundation and appearing in the file LICENSE.GPL included in the
# packaging of this file.  Please review the following information to
# ensure the GNU General Public License version 3.0 requirements will be
# met: http://www.gnu.org/copyleft/gpl.html.
#
#
# $QT_END_LICENSE$
#
#############################################################################

import glob
import os
import subprocess
import sys

extra_os = ['android', 'mac']

def subprocessCall(args):
    print args
    return subprocess.call(args)

def subprocessCheckOutput(args):
    print args
    return subprocess.check_output(args)

class DEPSParser:
    def __init__(self):
        self.global_scope = {
          'Var': self.Lookup,
          'deps_os': {},
        }
        self.local_scope = {}

    def Lookup(self, var_name):
        return self.local_scope["vars"][var_name]

    def createSubmodulesFromScope(self, scope, os):
        submodules = []
        for dep in scope:
            if (type(scope[dep]) == str):
                repo_rev = scope[dep].split('@')
                repo = repo_rev[0]
                rev = repo_rev[1]
                subdir = dep
                if subdir.startswith('src/'):
                    subdir = subdir[4:]
                submodule = Submodule(subdir, repo, rev, os)
                submodule.deps = True
                submodules.append(submodule)
        return submodules

    def sanityCheckModules(self, submodules):
        subdirectories = []
        for submodule in submodules:
            if submodule.path in subdirectories:
                print 'SUBMODULE WARNING: duplicate for submodule' + submodule.path
            subdirectories.append(submodule.path)

    def parseFile(self, deps_file_name):
        currentDir = os.getcwd()
        if not os.path.isfile(deps_file_name):
            return []
        deps_file = open(deps_file_name)
        deps_content = deps_file.read().decode('utf-8')
        deps_file.close()
        exec(deps_content, self.global_scope, self.local_scope)

        submodules = []
        submodules.extend(self.createSubmodulesFromScope(self.local_scope['deps'], 'all'))
        for os_dep in self.local_scope['deps_os']:
            submodules.extend(self.createSubmodulesFromScope(self.local_scope['deps_os'][os_dep], os_dep))

        self.sanityCheckModules(submodules)

        return submodules



class Submodule:
    def __init__(self, path='', url='', shasum='', os=[], ref=''):
        self.path = path
        self.url = url
        self.shasum = shasum
        self.os = os
        self.ref = ''
        self.deps = False

    def matchesOS(self):
        if not self.os:
            return True
        if 'all' in self.os:
            return True
        if (sys.platform.startswith('win32') or sys.platform.startswith('cygwin')) and 'win' in self.os:
            return True
        if sys.platform.startswith('linux') and 'unix' in self.os:
            return True
        if sys.platform.startswith('darwin') and ('unix' in self.os or 'mac' in self.os):
            return True
        for os in extra_os:
            if os in self.os:
                return True
        return False

    def findSha(self):
        if self.shasum != '':
            return
        line = subprocessCheckOutput(['git', 'submodule', 'status', self.path])
        line = line.lstrip(' -')
        self.shasum = line.split(' ')[0]

    def findGitDir(self):
        try:
            return subprocessCheckOutput(['git', 'rev-parse', '--git-dir']).strip()
        except subprocess.CalledProcessError, e:
            sys.exit("git dir could not be determined! - Initialization failed!" + e.output)

    def reset(self):
        currentDir = os.getcwd()
        os.chdir(self.path)
        gitdir = self.findGitDir()
        if os.path.isdir(os.path.join(gitdir, 'rebase-merge')):
            if os.path.isfile(os.path.join(gitdir, 'MERGE_HEAD')):
                print 'merge in progress... aborting merge.'
                subprocessCall(['git', 'merge', '--abort'])
            else:
                print 'rebase in progress... aborting merge.'
                subprocessCall(['git', 'rebase', '--abort'])
        if os.path.isdir(os.path.join(gitdir, 'rebase-apply')):
            print 'am in progress... aborting am.'
            subprocessCall(['git', 'am', '--abort'])
        subprocessCall(['git', 'reset', '--hard'])
        os.chdir(currentDir)

    def initialize(self):
        if self.matchesOS():
            print '-- initializing ' + self.path + ' --'
            if os.path.isdir(self.path):
                self.reset()
            if self.deps:
                subprocessCall(['git', 'submodule', 'add', '-f', self.url, self.path])
            subprocessCall(['git', 'submodule', 'init', self.path])
            subprocessCall(['git', 'submodule', 'update', self.path])
            self.findSha()
            currentDir = os.getcwd()
            os.chdir(self.path)
            # Make sure we have checked out the right shasum.
            # In case there were other patches applied before.
            if self.ref:
                val = subprocessCall(['git', 'fetch', 'origin', self.ref]);
                if val != 0:
                    sys.exit("Could not fetch branch from upstream.")
                subprocessCall(['git', 'checkout', 'FETCH_HEAD']);
            else:
                val = subprocessCall(['git', 'checkout', self.shasum])
                if val != 0:
                    sys.exit("!!! initialization failed !!!")
            self.initSubmodules()
            os.chdir(currentDir)
        else:
            print '-- skipping ' + self.path + ' for this operating system. --'

    def listFiles(self):
        if self.matchesOS() and os.path.isdir(self.path):
            currentDir = os.getcwd()
            os.chdir(self.path)
            files = subprocessCheckOutput(['git', 'ls-files']).splitlines()
            os.chdir(currentDir)
            return files
        else:
            print '-- skipping ' + self.path + ' for this operating system. --'
            return []


    def readSubmodules(self):
        if not os.path.isfile('.gitmodules'):
            return []
        gitmodules_file = open('.gitmodules')
        gitmodules_lines = gitmodules_file.readlines()
        gitmodules_file.close()

        submodules = []
        currentSubmodule = None
        for line in gitmodules_lines:
            if line.find('[submodule') == 0:
                if currentSubmodule:
                    submodules.append(currentSubmodule)
                currentSubmodule = Submodule()
            tokens = line.split('=')
            if len(tokens) >= 2:
                key = tokens[0].strip()
                value = tokens[1].strip()
                if key == 'path':
                    currentSubmodule.path = value
                elif key == 'url':
                    currentSubmodule.url = value
                elif key == 'os':
                    currentSubmodule.os = value.split(',')
        if currentSubmodule:
            submodules.append(currentSubmodule)
        return submodules

    def readDeps(self):
        parser = DEPSParser()
        return parser.parseFile('.DEPS.git')

    def initSubmodules(self):
        # try reading submodules from .gitmodules.
        submodules = self.readSubmodules()
        for submodule in submodules:
            submodule.initialize()
        if submodules:
            return
        # if we could not find any submodules in .gitmodules, try .DEPS.git
        submodules = self.readDeps()

        if not submodules:
            return

        print 'DEPS file provides the following submodules:'
        for submodule in submodules:
            print '{:<80}'.format(submodule.path) + '{:<120}'.format(submodule.url) + submodule.shasum
        for submodule in submodules:
            submodule.initialize()
        subprocessCall(['git', 'commit', '-a', '-m', '"initialize submodules"'])