WO2018098919A1 - Automatic update method and device for qt program - Google Patents

Automatic update method and device for qt program Download PDF

Info

Publication number
WO2018098919A1
WO2018098919A1 PCT/CN2017/075723 CN2017075723W WO2018098919A1 WO 2018098919 A1 WO2018098919 A1 WO 2018098919A1 CN 2017075723 W CN2017075723 W CN 2017075723W WO 2018098919 A1 WO2018098919 A1 WO 2018098919A1
Authority
WO
WIPO (PCT)
Prior art keywords
update
version number
value
module
file
Prior art date
Application number
PCT/CN2017/075723
Other languages
French (fr)
Chinese (zh)
Inventor
徐超
Original Assignee
武汉斗鱼网络科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 武汉斗鱼网络科技有限公司 filed Critical 武汉斗鱼网络科技有限公司
Publication of WO2018098919A1 publication Critical patent/WO2018098919A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Definitions

  • the present invention relates to the field of computer program technologies, and in particular, to a method and apparatus for automatically updating in a QT program.
  • the Qt program is a cross-platform C++ graphical user interface application development framework that can be used to develop both GUI programs and non-GUI programs such as console tools and servers.
  • Qt programs are object-oriented frameworks that use special code generation extensions, as well as some macros that are easy to extend and allow components to become.
  • the general update is simply to directly overwrite the new version of the file from the server to the local file, and does not involve the special case of modular update, update file check, update level mechanism, etc., and the general update The update check is performed as soon as the main program is started, and the update is frequently verified.
  • the general update, update information file structure is too complicated, and the update program cannot be updated.
  • the present invention provides a method and apparatus for automatically updating in a QT program, which can improve update efficiency and reduce update complexity, thereby being more suitable for practical use.
  • the method provided by the present invention for automatically updating in a QT program includes the following steps:
  • the method provided by the present invention for automatically updating in a QT program includes the following steps:
  • an update is initiated such that the update file overwrites corresponding local information
  • the local information is maintained.
  • the method for automatically updating in the QT program provided by the present invention can be further implemented by the following technical measures.
  • said parsing said update information file to obtain a parsed update information file comprises the steps of:
  • the error is updated and the error is recalled.
  • the version number of the local information is defined as a first version number
  • the version number of the parsed update information file is defined as a second version number
  • the recommended version number of the parsed update information file is defined as a third version. number
  • the comparing by comparing the parsed update information file and the corresponding local information, determining whether the corresponding local information needs to be updated includes the following steps:
  • the local information is maintained.
  • the method for calculating the MD5 value comprises the following steps:
  • the first MD5 value and the second MD5 value are notified to the main program by a checkback function of the update listener interface of the dynamic link library.
  • the method of automatically updating in the QT program further comprises the following steps:
  • the apparatus for automatically updating in a QT program includes an update information file acquiring unit, a comparison determining unit, and an updating unit,
  • the update information file obtaining unit is configured to acquire an update information file
  • the comparison determining unit is configured to determine whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information:
  • the update unit is configured to perform an update according to the determination result of the comparison determination unit, so that the update file covers the corresponding local information;
  • the local information is maintained when the result of the comparison judging unit is that no update is required.
  • the apparatus provided by the present invention for automatically updating in the QT program can be further implemented by the following technical measures.
  • the file parsing unit comprises a loading module, an error value judging module, a field returning module, and an update callback module.
  • the loading module is configured to load the update information file and return a text object and an error value
  • the error value judging module is configured to judge the returned text object and an error value:
  • the field return module returns a JSON object through the text object, and returns each field value in the form of a key value pair to obtain the Parsed update information file;
  • the The update callback module is used to update the error and call back the error.
  • said means for automatically updating in the QT program further comprises an MD5 value calculation unit,
  • the MD5 value calculation unit includes a hash function acquisition module, a file data addition module, and an MD5 value calculation return module.
  • the hash function obtaining module is configured to obtain a hash function object of the file object to be calculated
  • the file data adding module is configured to apply the hash function object to add file data to be calculated
  • the MD5 value calculation returning module is configured to calculate and return an MD5 value of the file to be calculated according to the file data to be calculated.
  • the comparison determination unit comprises a first comparison module and/or a second comparison module and/or a second comparison module and/or a third comparison module,
  • the first comparison module is configured to compare the first version number and the second version number, and when the first version number and the second version number are not equal, start an update; when the first version number and the When the second version numbers are equal, the local information is maintained;
  • the second comparison module is configured to compare the first version number and the third version number, and when the first version number and the third version number are not equal, start an update; when the first version number and the When the third version number is equal, the local information is maintained;
  • the third comparison module is configured to compare the first MD5 value and the second MD5 value, if the first MD5 value is not equal to the second MD5 value, initiate an update; if the first MD5 value is If the second MD5 values are equal, the local information is maintained;
  • the first version number is a version number of the local information
  • the second version number is a version number of the parsed update information file
  • the third version number is a suggested version of the parsed update information file. number
  • the first MD5 value is an MD5 value of local information
  • the second MD5 value is an MD5 value of the parsed update information file.
  • said means for automatically updating in the QT program further comprises an update restriction unit,
  • the update restriction unit includes an update time acquisition module, an update time difference calculation module, and an update time difference comparison determination module.
  • the update time acquisition module is configured to acquire times T 1 and T 2 when the update is initiated twice;
  • the update difference comparing and judging means for comparing between two adjacent start the update time difference t and the updated threshold value t 0 of the magnitude relationship, and decide whether to start the update:
  • the method and the device for automatically updating in the QT program provided by the present invention first obtain an update information file; after that, after comparing the parsed update information file and the corresponding local information, it is determined whether the corresponding local information needs to be updated. : If an update is needed, the update is initiated such that the update file overwrites the corresponding local information; if no update is required, the local information is maintained. Since there is a step of judging whether or not an update is required, the update is started only when it is determined that the corresponding local information needs to be updated, and is not updated when it is determined that the corresponding local information does not need to be updated, thereby avoiding A frequent verification update caused by an update check is performed as soon as the main program is started. Therefore, it can improve the update efficiency and reduce the update complexity.
  • FIG. 1 is a flow chart showing the steps of a method for automatically updating in a QT program according to Embodiment 1 of the present invention
  • FIG. 2 is a schematic diagram of a signal flow relationship relationship between devices automatically updated in a QT program according to Embodiment 2 of the present invention.
  • the present invention provides a method and apparatus for automatically updating in a QT program, which can improve the update efficiency and reduce the update complexity, thereby being more suitable for practical use.
  • a and B in this context is merely an association that describes an associated object, indicating that there may be three relationships, for example, A and/or B.
  • a and B can be included at the same time, and can be separate. If A exists, B may exist alone, and any of the above three cases may be provided.
  • a method for automatically updating in a QT program according to Embodiment 1 of the present invention includes Next steps:
  • Step 101 Obtain an update information file.
  • the update information file is a JSON format file
  • the tree structure of the JSON format file includes three layers; wherein the first layer is an update information layer, and the update information layer is used for saving information including a version number, an update time, and a suggestion.
  • the second layer is the module information layer, the information used by the module information layer includes the module name, the version number, and the size;
  • the third layer is the update file information layer, and the updated file information layer is used to save the information including File name, file MD5 value, file path.
  • the JSON format file is the most efficient, and the file is designed as a three-layer tree structure, which can reduce the complexity of updating information. Specifically, the decrease in complexity is achieved by layering the updated basic information with the updated file information, and separating the update files in units of modules.
  • Step 102 The files that are transmitted by the network need to be compressed. Therefore, after the step 101, the updated information file needs to be decompressed to obtain the decompressed update information file.
  • the update information file is in the RAR or ZIP format. Compressed file.
  • Step 103 Parse the decompressed update information file to obtain a parsed update information file.
  • parsing the decompressed update information file to obtain the parsed update information file includes the following steps: Step 1031: Load the decompressed update information file and return the text object and the error value; Step 1032: The text object and the error value are judged: if the text object does not have the error information, step 1033 is executed: the JSON object is returned by the text object, and each field value is returned in the form of a key-value pair to obtain the parsed update information file; If there is an error message in the text object, go to step 1034: Update the error and call back the error.
  • Step 104 Determine whether the corresponding local information needs to be updated by comparing the parsed update information file with the corresponding local information:
  • step 105 is performed to start the update, so that the update file covers the corresponding local information
  • the first mode of determining whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information includes the following steps: Step 10411: Define a version number of the local information as the first version number, Defining the version number of the parsed update information file as the second version number; Step 10412: Comparing the string of the first version number with the string of the second version number: Step 10413: If the string of the first version number is the second If the string of the version number is not equal, the update is started; Step 10414: If the string of the first version number is equal to the string of the second version number, the local information is maintained.
  • the second method of determining whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information includes the following steps: Step 10421: Define the version number of the local information as the first version number. Defining the recommended version number of the parsed update information file as the third version number; Step 10422: Comparing the string of the first version number with the string of the third version number: Step 10423: If the string of the first version number and the first If the strings of the three version numbers are not equal, the update is started; Step 10424: If the string of the first version number is equal to the string of the third version number, the local information is maintained.
  • the comparison of the next field is continued until the comparison is obtained, and the first version number is considered to be small, and the update is started.
  • the first version number is 1.0.1 and the second version number is 1.1.0
  • the second field is performed because the first field of the first version number and the first field of the second version number are both “1”.
  • the comparison because the first field of the first version number is "0", and the second field of the second version number is "1", can get unequal results, at this time, I think the first version number is small.
  • the fuzzy update is started, that is, the random update is performed according to the random number.
  • the fuzzy update is started, that is, the random update is performed according to the random number.
  • the third mode of determining whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information includes the following steps: Step 10431: Calculate the MD5 value of the local information and obtain the first MD5 value. Calculating the MD5 value of the parsed update information file and obtaining the second MD5 value; Step 10432: If the first MD5 value is not equal to the second MD5 value, starting the update; Step 10433: If the first MD5 value and the second MD5 If the values are equal, the local information is maintained.
  • the first MD5 value and the second MD5 value are notified to the main program by using a checkback function of the update listener interface of the dynamic link library, and the dynamic link database is specifically:
  • the method of automatically updating in the QT program further includes the following steps between step 104 and step 105:
  • Step z1 obtaining times T 1 and T 2 of the two adjacent start-ups
  • Step z3 Compare the relationship between the time difference t of the two adjacent start-up updates and the update threshold t 0 : when t>t 0 , the update is initiated; when t ⁇ t 0 , the update is rejected.
  • the method for automatically updating in the QT program provided by the present invention first obtains an update information file; after that, decompressing the update information file to obtain a decompressed update information file; and then parsing the decompressed update information file, Obtaining the parsed update information file; then, by comparing the parsed update information file and the corresponding local information, determining whether the corresponding local information needs to be updated: if an update is required, starting the update, so that the update file is Overwrite the corresponding local information; if no updates are needed, maintain local information.
  • the update Since there is a step of judging whether or not an update is required, the update is started only when it is determined that the corresponding local information needs to be updated, and is not updated when it is determined that the corresponding local information does not need to be updated, thereby avoiding A frequent verification update caused by an update check is performed as soon as the main program is started. Therefore, it can improve the update efficiency and reduce the update complexity.
  • an apparatus for automatically updating in a QT program includes an update information file obtaining unit 201, a decompressing unit 202, a file parsing unit 203, a comparison judging unit 204, and an updating unit 205.
  • the update information file obtaining unit 201 is configured to obtain an update information file; the decompression unit 202 is configured to decompress the update information file to obtain a decompressed update information file; and the file parsing unit 203 is configured to parse the decompressed update information file to obtain The parsed update information file; the comparison judging unit 204 is configured to judge whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information: when the result of the comparison judging unit 204 needs to be updated, the update unit 205 is configured to update according to the judgment result of the comparison judgment unit, so that the update file covers the corresponding local information; when the result of the comparison judgment unit 204 does not need to be updated, the local information is maintained.
  • the file parsing unit 203 includes a loading module, an error value judging module, and a field return module.
  • Update the callback module The loading module is configured to load the decompressed update information file and return a text object and an error value; the error value judging module is configured to judge the returned text object and the error value: when the error value judging module judges that the text object does not exist In the error message, the field return module returns the JSON object through the text object, and returns each field value in the form of a key-value pair to obtain the parsed update information file; when the error value judgment module determines that the text object has an error message
  • the update callback module is used to update the error and call back the error.
  • the device automatically updated in the QT program further includes an MD5 value calculation unit.
  • the MD5 value calculation unit includes a hash function acquisition module, a file data addition module, and an MD5 value calculation return module.
  • the hash function obtaining module is configured to obtain a hash function object of the file object to be calculated;
  • the file data adding module is configured to apply the hash function object to add the to-be-calculated file data;
  • the MD5 value calculation returning module is configured to calculate and return according to the file data to be calculated. MD5 value of the file to be calculated.
  • the comparison judging unit 204 includes a first comparison module and/or a second comparison module and/or a second comparison module and/or a third comparison module.
  • the first comparison module is configured to compare the first version number and the second version number. When the first version number and the second version number are not equal, the update is started; when the first version number is equal to the second version number, the first version is maintained. Local information.
  • the second comparison module is configured to compare the first version number and the third version number. When the first version number and the third version number are not equal, the update is started; when the first version number is equal to the third version number, the Local information.
  • the third comparison module is configured to compare the first MD5 value and the second MD5 value, and if the first MD5 value and the second MD5 value are not equal, start an update; if the first MD5 value is equal to the second MD5 value, the local information is maintained. .
  • the first version number is the version number of the local information
  • the second version number is the version number of the parsed update information file
  • the third version number is the suggested version number of the parsed update information file.
  • the first MD5 value is the MD5 value of the local information
  • the second MD5 value is the MD5 value of the parsed update information file.
  • the device that is automatically updated in the QT program further includes an update restriction unit.
  • the update restriction unit includes an update time acquisition module, an update time difference calculation module, and an update time difference comparison determination module.
  • the update time acquisition module is configured to acquire the times T 1 and T 2 of the two adjacent start updates;
  • the module is used to compare the magnitude relationship between the time difference t of the two adjacent start-up updates and the update threshold t 0 , and decide whether to start the update: when t>t 0 , the update is initiated; when t ⁇ t 0 , the update is rejected. In this case, frequent updates can be avoided.
  • the device automatically updated in the QT program provided by the present invention first obtains the update information file by the update information file obtaining unit 201; after that, the decompressing unit 202 decompresses the update information file to obtain the decompressed update information file; And parsing the decompressed update information file by the file parsing unit 203 to obtain the parsed update information file; and then comparing the parsed update information file and the corresponding local information by the comparison judging unit 204, determining the Whether the corresponding local information needs to be updated: if an update is required, the update is initiated by the update unit 205 so that the update file overwrites the corresponding local information; if no update is required, the local information is maintained.
  • the update unit Since the comparison judging unit 204 is present, the update unit is triggered to start the update only when it is determined that the corresponding local information needs to be updated, and the update unit 205 is not triggered to be updated when it is determined that the corresponding local information does not need to be updated. Therefore, it is possible to avoid frequent verification updates caused by the update check as long as the main program is started. Therefore, it can improve the update efficiency and reduce the update complexity.

Abstract

The present invention relates to the technical field of computer programs, and particularly relates to an automatic update method and device for a Qt program. The method comprises: acquiring an update information file (101); determining, by means of comparing a parsing result of the update information file against corresponding local information, whether the corresponding local information needs an update (104); if so, then initiating an update to overwrite the corresponding local information with an update file (105); and if not, then preserving the local information. The device of the present invention can be employed to implement the above method. The method and device of the present invention improve update efficiency and reduce update complexity.

Description

在QT程序中自动更新的方法及装置Method and device for automatically updating in QT program 技术领域Technical field
本发明涉及计算机程序技术领域,特别是涉及一种在QT程序中自动更新的方法及装置。The present invention relates to the field of computer program technologies, and in particular, to a method and apparatus for automatically updating in a QT program.
背景技术Background technique
Qt程序是一个跨平台C++图形用户界面应用程序开发框架,它既可以开发GUI程序,也可用于开发非GUI程序,比如控制台工具和服务器。Qt程序是面向对象的框架,使用特殊的代码生成扩展,以及一些宏,易于扩展,允许组件变成。在Qt程序完成开发发布以后,会有一个自动更新版本的功能。然而,一般的更新都是简单的从服务器将新版本文件直接覆盖到本地文件中,并没有涉及到模块化更新、更新文件校验、更新级别机制等特殊情况的处理,并且,一般的更新都是只要主程序启动就进行更新检查,都是频繁验证更新。此外,一般的更新,更新信息文件结构过于复杂,并且,更新程序无法更新。The Qt program is a cross-platform C++ graphical user interface application development framework that can be used to develop both GUI programs and non-GUI programs such as console tools and servers. Qt programs are object-oriented frameworks that use special code generation extensions, as well as some macros that are easy to extend and allow components to become. After the development of the Qt program is released, there will be an automatic update version. However, the general update is simply to directly overwrite the new version of the file from the server to the local file, and does not involve the special case of modular update, update file check, update level mechanism, etc., and the general update The update check is performed as soon as the main program is started, and the update is frequently verified. In addition, the general update, update information file structure is too complicated, and the update program cannot be updated.
发明内容Summary of the invention
有鉴于此,本发明提供了一种在QT程序中自动更新的方法及装置,其能够使得更新效率提高,更新复杂度降低,从而更加适于实用。In view of this, the present invention provides a method and apparatus for automatically updating in a QT program, which can improve update efficiency and reduce update complexity, thereby being more suitable for practical use.
为了达到上述第一个目的,本发明提供的在QT程序中自动更新的方法的技术方案如下:In order to achieve the above first object, the technical solution of the method for automatically updating in the QT program provided by the present invention is as follows:
本发明提供的在QT程序中自动更新的方法包括以下步骤:The method provided by the present invention for automatically updating in a QT program includes the following steps:
本发明提供的在QT程序中自动更新的方法包括以下步骤:The method provided by the present invention for automatically updating in a QT program includes the following steps:
获取更新信息文件; Obtain an update information file;
通过比较经过解析的所述更新信息文件和对应的本地信息,判断所述对应的本地信息是否需要更新:Determining whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information:
如需要更新,则启动更新,使得所述更新文件覆盖对应的本地信息;If an update is required, an update is initiated such that the update file overwrites corresponding local information;
如不需要更新,则维持所述本地信息。If the update is not required, the local information is maintained.
本发明提供的在QT程序中自动更新的方法还可采用以下技术措施进一步实现。The method for automatically updating in the QT program provided by the present invention can be further implemented by the following technical measures.
作为优选,所述解析所述更新信息文件,得到经过解析的更新信息文件包括以下步骤:Advantageously, said parsing said update information file to obtain a parsed update information file comprises the steps of:
加载所述更新信息文件并返回文本对象和错误值;Loading the update information file and returning text objects and error values;
对所述返回的文本对象和错误值进行判断:Judge the returned text object and the error value:
若所述文本对象不存在错误信息,则通过文本对象返回JSON对象,并采用键值对的形式返回每个字段值,得到所述经过解析的更新信息文件;If the text object does not have an error message, returning the JSON object through the text object, and returning each field value in the form of a key-value pair to obtain the parsed update information file;
若所述文本对象存在错误信息,则更新错误并回调所述错误。If the text object has an error message, the error is updated and the error is recalled.
作为优选,定义本地信息的版本号为第一版本号,定义所述经过解析的更新信息文件的版本号为第二版本号,定义所述经过解析的更新信息文件的建议版本号为第三版本号;Preferably, the version number of the local information is defined as a first version number, the version number of the parsed update information file is defined as a second version number, and the recommended version number of the parsed update information file is defined as a third version. number;
所述通过比较所述经过解析的更新信息文件和对应的本地信息,判断所述对应的本地信息是否需要更新包括以下步骤:The comparing, by comparing the parsed update information file and the corresponding local information, determining whether the corresponding local information needs to be updated includes the following steps:
比较所述第一版本号的字符串与所述第二版本号的字符串:Comparing the string of the first version number with the string of the second version number:
若所述第一版本号的字符串与所述第二版本号的字符串不等,则启动更新;If the character string of the first version number is not equal to the character string of the second version number, starting an update;
若所述第一版本号的字符串与所述第二版本号的字符串相等,则维持所述 本地信息;If the character string of the first version number is equal to the character string of the second version number, maintaining the Local information;
和/或,and / or,
比较所述第一版本号的字符串与所述第三版本号的字符串:Comparing the string of the first version number with the string of the third version number:
若所述第一版本号的字符串与所述第三版本号的字符串不等,则启动更新;If the character string of the first version number is not equal to the character string of the third version number, starting an update;
若所述第一版本号的字符串与所述第三版本号的字符串相等,则维持所述本地信息;If the character string of the first version number is equal to the character string of the third version number, maintaining the local information;
和/或,and / or,
计算本地信息的MD5值并得到第一MD5值,计算所述经过解析的更新信息文件的MD5值并得到第二MD5值:Calculating the MD5 value of the local information and obtaining the first MD5 value, calculating the MD5 value of the parsed update information file and obtaining the second MD5 value:
若所述第一MD5值与所述第二MD5值不等,则启动更新;If the first MD5 value is not equal to the second MD5 value, starting an update;
若所述第一MD5值与所述第二MD5值相等,则维持所述本地信息。If the first MD5 value is equal to the second MD5 value, the local information is maintained.
作为优选,所述MD5值的计算方法包括以下步骤:Preferably, the method for calculating the MD5 value comprises the following steps:
获取待计算文件对象的散列函数对象;Obtaining a hash function object of the file object to be calculated;
应用所述散列函数对象添加待计算文件数据;Applying the hash function object to add file data to be calculated;
根据所述待计算文件数据计算并返回所述待计算文件的MD5值;Calculating and returning an MD5 value of the file to be calculated according to the file data to be calculated;
其中,所述第一MD5值与所述第二MD5值是通过动态链接库的更新监听接口的检查回调函数通知主程序的。The first MD5 value and the second MD5 value are notified to the main program by a checkback function of the update listener interface of the dynamic link library.
作为优选,所述在QT程序中自动更新的方法还包括以下步骤:Preferably, the method of automatically updating in the QT program further comprises the following steps:
获取相邻两次启动更新的时刻T1和T2Get two starts adjacent to the updated time T 1 and T 2;
计算所述相邻两次启动更新的时间差t=|T2-T1|;Calculating a time difference t=|T 2 -T 1 | of the two adjacent startup updates;
比较相邻两次启动更新的时间差t与更新阈值t0的大小关系: Compare the relationship between the time difference t of the two adjacent start-up updates and the update threshold t 0 :
当t>t0时,启动更新;When t>t 0 , the update is started;
当t≤t0时,拒绝更新。When t ≤ t 0 , the update is rejected.
为了达到上述第二个目的,本发明提供的在QT程序中自动更新的装置的技术方案如下:In order to achieve the above second object, the technical solution of the device automatically updated in the QT program provided by the present invention is as follows:
本发明提供的在QT程序中自动更新的装置包括更新信息文件获取单元、比较判断单元、更新单元,The apparatus for automatically updating in a QT program provided by the present invention includes an update information file acquiring unit, a comparison determining unit, and an updating unit,
所述更新信息文件获取单元用于获取更新信息文件;The update information file obtaining unit is configured to acquire an update information file;
所述比较判断单元用于通过比较经过解析的所述更新信息文件和对应的本地信息,判断所述对应的本地信息是否需要更新:The comparison determining unit is configured to determine whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information:
当所述比较判断单元的结果是需要更新时,所述更新单元用于根据所述比较判断单元的判断结果,进行更新,使得所述更新文件覆盖对应的本地信息;When the result of the comparison determination unit is that the update is required, the update unit is configured to perform an update according to the determination result of the comparison determination unit, so that the update file covers the corresponding local information;
当所述比较判断单元的结果是不需要更新时,维持所述本地信息。The local information is maintained when the result of the comparison judging unit is that no update is required.
本发明提供的在QT程序中自动更新的装置还可采用以下技术措施进一步实现。The apparatus provided by the present invention for automatically updating in the QT program can be further implemented by the following technical measures.
作为优选,所述文件解析单元包括加载模块、错误值判断模块、字段返回模块、更新回调模块,Preferably, the file parsing unit comprises a loading module, an error value judging module, a field returning module, and an update callback module.
所述加载模块用于加载所述更新信息文件并返回文本对象和错误值;The loading module is configured to load the update information file and return a text object and an error value;
所述错误值判断模块用于对所述返回的文本对象和错误值进行判断:The error value judging module is configured to judge the returned text object and an error value:
当所述错误值判断模块的判断结果为所述文本对象不存在错误信息时,所述字段返回模块通过文本对象返回JSON对象,并采用键值对的形式返回每个字段值,得到所述经过解析的更新信息文件;When the judgment result of the error value judgment module is that the text object does not have error information, the field return module returns a JSON object through the text object, and returns each field value in the form of a key value pair to obtain the Parsed update information file;
当所述错误值判断模块的判断结果为所述文本对象存在错误信息时,所述 更新回调模块用于更新错误并回调所述错误。When the judgment result of the error value judgment module is that the text object has error information, the The update callback module is used to update the error and call back the error.
作为优选,所述在QT程序中自动更新的装置还包括MD5值计算单元,Advantageously, said means for automatically updating in the QT program further comprises an MD5 value calculation unit,
所述MD5值计算单元包括散列函数获取模块、文件数据添加模块、MD5值计算返回模块,The MD5 value calculation unit includes a hash function acquisition module, a file data addition module, and an MD5 value calculation return module.
所述散列函数获取模块用于获取待计算文件对象的散列函数对象;The hash function obtaining module is configured to obtain a hash function object of the file object to be calculated;
所述文件数据添加模块用于应用所述散列函数对象添加待计算文件数据;The file data adding module is configured to apply the hash function object to add file data to be calculated;
所述MD5值计算返回模块用于根据所述待计算文件数据计算并返回所述待计算文件的MD5值。The MD5 value calculation returning module is configured to calculate and return an MD5 value of the file to be calculated according to the file data to be calculated.
作为优选,所述比较判断单元包括第一比较模块和/或第二比较模块和/或第二比较模块和/或第三比较模块,Advantageously, the comparison determination unit comprises a first comparison module and/or a second comparison module and/or a second comparison module and/or a third comparison module,
所述第一比较模块用于比较第一版本号和第二版本号,当所述第一版本号与所述第二版本号不等时,则启动更新;当所述第一版本号与所述第二版本号相等时,则维持所述本地信息;The first comparison module is configured to compare the first version number and the second version number, and when the first version number and the second version number are not equal, start an update; when the first version number and the When the second version numbers are equal, the local information is maintained;
所述第二比较模块用于比较第一版本号和第三版本号,当所述第一版本号与所述第三版本号不等时,则启动更新;当所述第一版本号与所述第三版本号相等时,则维持所述本地信息;The second comparison module is configured to compare the first version number and the third version number, and when the first version number and the third version number are not equal, start an update; when the first version number and the When the third version number is equal, the local information is maintained;
所述第三比较模块用于比较第一MD5值和第二MD5值,若所述第一MD5值与所述第二MD5值不等,则启动更新;若所述第一MD5值与所述第二MD5值相等,则维持所述本地信息;The third comparison module is configured to compare the first MD5 value and the second MD5 value, if the first MD5 value is not equal to the second MD5 value, initiate an update; if the first MD5 value is If the second MD5 values are equal, the local information is maintained;
其中,among them,
所述第一版本号为本地信息的版本号,所述第二版本号为经过解析的更新信息文件的版本号,所述第三版本号为经过解析的更新信息文件的建议版本 号;The first version number is a version number of the local information, the second version number is a version number of the parsed update information file, and the third version number is a suggested version of the parsed update information file. number;
所述第一MD5值为本地信息的MD5值,所述第二MD5值为经过解析的更新信息文件的MD5值。The first MD5 value is an MD5 value of local information, and the second MD5 value is an MD5 value of the parsed update information file.
作为优选,所述在QT程序中自动更新的装置还包括更新限制单元,Advantageously, said means for automatically updating in the QT program further comprises an update restriction unit,
所述更新限制单元包括更新时刻获取模块、更新时差计算模块、更新时差比较判断模块,The update restriction unit includes an update time acquisition module, an update time difference calculation module, and an update time difference comparison determination module.
所述更新时刻获取模块用于获取相邻两次启动更新的时刻T1和T2The update time acquisition module is configured to acquire times T 1 and T 2 when the update is initiated twice;
所述更新时差计算模块用于计算所述相邻两次启动更新的时间差t=|T2-T1|;Updating the time difference calculation module for calculating the starting time of the update of two adjacent difference t = | T 2 -T 1 | ;
所述更新时差比较判断模块用于比较相邻两次启动更新的时间差t与更新阈值t0的大小关系,并决定是否启动更新:The update difference comparing and judging means for comparing between two adjacent start the update time difference t and the updated threshold value t 0 of the magnitude relationship, and decide whether to start the update:
当t>t0时,启动更新;When t>t 0 , the update is started;
当t≤t0时,拒绝更新。When t≤t 0, the refusal update.
本发明提供的在QT程序中自动更新的方法及装置首先获取更新信息文件;之后,之后,通过比较经过解析的所述更新信息文件和对应的本地信息,判断所述对应的本地信息是否需要更新:如需要更新,则启动更新,使得所述更新文件覆盖对应的本地信息;如不需要更新,则维持本地信息。由于其中存在对是否需要更新进行判断的步骤,只有在判断为对应的本地信息需要更新的时候才启动更新,而在判断为对应的本地信息不需要更新的时候则不予更新,因此,能够避免只要主程序启动就进行更新检查造成的频繁验证更新。因此,其能够提高更新效率,降低更新复杂度。 The method and the device for automatically updating in the QT program provided by the present invention first obtain an update information file; after that, after comparing the parsed update information file and the corresponding local information, it is determined whether the corresponding local information needs to be updated. : If an update is needed, the update is initiated such that the update file overwrites the corresponding local information; if no update is required, the local information is maintained. Since there is a step of judging whether or not an update is required, the update is started only when it is determined that the corresponding local information needs to be updated, and is not updated when it is determined that the corresponding local information does not need to be updated, thereby avoiding A frequent verification update caused by an update check is performed as soon as the main program is started. Therefore, it can improve the update efficiency and reduce the update complexity.
附图说明DRAWINGS
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those skilled in the art from a The drawings are only for the purpose of illustrating the preferred embodiments and are not to be construed as limiting. Throughout the drawings, the same reference numerals are used to refer to the same parts. In the drawing:
图1为本发明实施例一提供的在QT程序中自动更新的方法的步骤流程图;1 is a flow chart showing the steps of a method for automatically updating in a QT program according to Embodiment 1 of the present invention;
图2为本发明实施例二提供的在QT程序中自动更新的装置的信号流向关系示意图。FIG. 2 is a schematic diagram of a signal flow relationship relationship between devices automatically updated in a QT program according to Embodiment 2 of the present invention.
具体实施方式detailed description
本发明为解决现有技术存在的问题,提供一种在QT程序中自动更新的方法及装置,其能够使得更新效率提高,更新复杂度降低,从而更加适于实用。In order to solve the problems existing in the prior art, the present invention provides a method and apparatus for automatically updating in a QT program, which can improve the update efficiency and reduce the update complexity, thereby being more suitable for practical use.
为更进一步阐述本发明为达成预定发明目的所采取的技术手段及功效,以下结合附图及较佳实施例,对依据本发明提出的在QT程序中自动更新的方法及装置,其具体实施方式、结构、特征及其功效,详细说明如后。在下述说明中,不同的“一实施例”或“实施例”指的不一定是同一实施例。此外,一或多个实施例中的特定特征、结构、或特点可由任何合适形式组合。In order to further explain the technical means and functions of the present invention for achieving the intended purpose of the invention, the following describes a method and an apparatus for automatically updating in a QT program according to the present invention with reference to the accompanying drawings and preferred embodiments. , structure, characteristics and efficacy, as detailed below. In the following description, different "an embodiment" or "an embodiment" does not necessarily mean the same embodiment. Furthermore, the particular features, structures, or characteristics of one or more embodiments can be combined in any suitable form.
本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,具体的理解为:可以同时包含有A与B,可以单独存在A,也可以单独存在B,能够具备上述三种任一种情况。The term “and/or” in this context is merely an association that describes an associated object, indicating that there may be three relationships, for example, A and/or B. The specific understanding is that A and B can be included at the same time, and can be separate. If A exists, B may exist alone, and any of the above three cases may be provided.
实施例一Embodiment 1
参见附图1,本发明实施例一提供的在QT程序中自动更新的方法包括以 下步骤:Referring to FIG. 1, a method for automatically updating in a QT program according to Embodiment 1 of the present invention includes Next steps:
步骤101:获取更新信息文件;Step 101: Obtain an update information file.
本实施例中,更新信息文件是JSON格式文件,JSON格式文件的树形结构包括三层;其中,第一层为更新信息层,更新信息层用于保存的信息包括版本号、更新时间、建议版本号、更新大小;第二层为模块信息层,模块信息层用于保存的信息包括模块名称、版本号、大小;第三层为更新文件信息层,更新文件信息层用于保存的信息包括文件名、文件MD5值、文件路径。其中,JSON格式的文件效率最好,将文件设计为三层的树型结构,能够降低更新信息的复杂度。具体地说,复杂度的下降是通过将更新的基本信息与更新的文件信息进行分层,在把更新文件以模块为单位进行隔开来达到的。In this embodiment, the update information file is a JSON format file, and the tree structure of the JSON format file includes three layers; wherein the first layer is an update information layer, and the update information layer is used for saving information including a version number, an update time, and a suggestion. The version number and the update size; the second layer is the module information layer, the information used by the module information layer includes the module name, the version number, and the size; the third layer is the update file information layer, and the updated file information layer is used to save the information including File name, file MD5 value, file path. Among them, the JSON format file is the most efficient, and the file is designed as a three-layer tree structure, which can reduce the complexity of updating information. Specifically, the decrease in complexity is achieved by layering the updated basic information with the updated file information, and separating the update files in units of modules.
步骤102:由于网络传播的文件都需要进行压缩,因此,在步骤101之后还需要解压缩更新信息文件,得到解压缩后的更新信息文件;本实施例中,更新信息文件为RAR或者ZIP格式的压缩文件。Step 102: The files that are transmitted by the network need to be compressed. Therefore, after the step 101, the updated information file needs to be decompressed to obtain the decompressed update information file. In this embodiment, the update information file is in the RAR or ZIP format. Compressed file.
步骤103:解析解压缩后的更新信息文件,得到经过解析的更新信息文件;Step 103: Parse the decompressed update information file to obtain a parsed update information file.
本实施例中,解析解压缩后的更新信息文件,得到经过解析的更新信息文件包括以下步骤:步骤1031:加载解压缩后的更新信息文件并返回文本对象和错误值;步骤1032:对返回的文本对象和错误值进行判断:若文本对象不存在错误信息,则执行步骤1033:通过文本对象返回JSON对象,并采用键值对的形式返回每个字段值,得到经过解析的更新信息文件;若文本对象存在错误信息,则执行步骤1034:更新错误并回调错误。In this embodiment, parsing the decompressed update information file to obtain the parsed update information file includes the following steps: Step 1031: Load the decompressed update information file and return the text object and the error value; Step 1032: The text object and the error value are judged: if the text object does not have the error information, step 1033 is executed: the JSON object is returned by the text object, and each field value is returned in the form of a key-value pair to obtain the parsed update information file; If there is an error message in the text object, go to step 1034: Update the error and call back the error.
步骤104:通过比较经过解析的更新信息文件和对应的本地信息,判断对应的本地信息是否需要更新: Step 104: Determine whether the corresponding local information needs to be updated by comparing the parsed update information file with the corresponding local information:
如需要更新,则执行步骤105:启动更新,使得更新文件覆盖对应的本地信息;If the update is required, step 105 is performed to start the update, so that the update file covers the corresponding local information;
如不需要更新,则返回执行步骤101。If no update is needed, go back to step 101.
其中,步骤104通过比较经过解析的更新信息文件和对应的本地信息,判断对应的本地信息是否需要更新的第一种方式包括以下步骤:步骤10411:定义本地信息的版本号为第一版本号,定义经过解析的更新信息文件的版本号为第二版本号;步骤10412:比较第一版本号的字符串与第二版本号的字符串:步骤10413:若第一版本号的字符串与第二版本号的字符串不等,则启动更新;步骤10414:若第一版本号的字符串与第二版本号的字符串相等,则维持本地信息。The first mode of determining whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information includes the following steps: Step 10411: Define a version number of the local information as the first version number, Defining the version number of the parsed update information file as the second version number; Step 10412: Comparing the string of the first version number with the string of the second version number: Step 10413: If the string of the first version number is the second If the string of the version number is not equal, the update is started; Step 10414: If the string of the first version number is equal to the string of the second version number, the local information is maintained.
其中,步骤104通过比较经过解析的更新信息文件和对应的本地信息,判断对应的本地信息是否需要更新的第二种方式包括以下步骤:步骤10421:定义本地信息的版本号为第一版本号,定义经过解析的更新信息文件的建议版本号为第三版本号;步骤10422:比较第一版本号的字符串与第三版本号的字符串:步骤10423:若第一版本号的字符串与第三版本号的字符串不等,则启动更新;步骤10424:若第一版本号的字符串与第三版本号的字符串相等,则维持本地信息。The second method of determining whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information includes the following steps: Step 10421: Define the version number of the local information as the first version number. Defining the recommended version number of the parsed update information file as the third version number; Step 10422: Comparing the string of the first version number with the string of the third version number: Step 10423: If the string of the first version number and the first If the strings of the three version numbers are not equal, the update is started; Step 10424: If the string of the first version number is equal to the string of the third version number, the local information is maintained.
其中,在比较第一版本号与第二版本号时,当前一字段相同时,继续进行下一字段的比较,直到比较得到不等,认为第一版本号小,启动更新。例如,当第一版本号为1.0.1,第二版本号为1.1.0时,由于第一版本号的第一字段和第二版本号的第一字段均为“1”,进行第二字段的比较,因为第一版本号的第一字段为“0”,而第二版本号的第二字段为“1”,能够得到不等的结果,此时, 认为第一版本号小。When comparing the first version number and the second version number, when the current field is the same, the comparison of the next field is continued until the comparison is obtained, and the first version number is considered to be small, and the update is started. For example, when the first version number is 1.0.1 and the second version number is 1.1.0, the second field is performed because the first field of the first version number and the first field of the second version number are both “1”. The comparison, because the first field of the first version number is "0", and the second field of the second version number is "1", can get unequal results, at this time, I think the first version number is small.
或者,比较第一版本号与第三版本号时,当第一版本号与第二版本号不等时,启模糊更新,也就是根据随机数进行随机更新。例如,当第一版本号为1.0.1,第三版本号为1.1.0,比较过程中,由于1.0.1≠1.1.0,因此,启动模糊更新,也就是根据随机数进行随机更新。Alternatively, when comparing the first version number and the third version number, when the first version number and the second version number are not equal, the fuzzy update is started, that is, the random update is performed according to the random number. For example, when the first version number is 1.0.1 and the third version number is 1.1.0, during the comparison, since 1.0.1≠1.1.0, the fuzzy update is started, that is, the random update is performed according to the random number.
其中,步骤104通过比较经过解析的更新信息文件和对应的本地信息,判断对应的本地信息是否需要更新的第三种方式包括以下步骤:步骤10431:计算本地信息的MD5值并得到第一MD5值;计算经过解析的更新信息文件的MD5值并得到第二MD5值;步骤10432:若第一MD5值与第二MD5值不等,则启动更新;步骤10433:若第一MD5值与第二MD5值相等,则维持本地信息。The third mode of determining whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information includes the following steps: Step 10431: Calculate the MD5 value of the local information and obtain the first MD5 value. Calculating the MD5 value of the parsed update information file and obtaining the second MD5 value; Step 10432: If the first MD5 value is not equal to the second MD5 value, starting the update; Step 10433: If the first MD5 value and the second MD5 If the values are equal, the local information is maintained.
其中,MD5值的计算方法包括以下步骤:步骤104311:使用QT QCryptographicHash hash(QCryptographicHash::Md5)获取待计算文件对象的散列函数对象;步骤104312:应用散列函数对象的adddata方法添加待计算文件数据;步骤104313:根据待计算文件数据,通过md5C=hash.result().toHex();计算并返回待计算文件的MD5值。The method for calculating the value of the MD5 includes the following steps: Step 104311: Acquire a hash function object of the file object to be calculated using the QT QCryptographicHash hash (QCryptographicHash::Md5); Step 104312: Add the file to be calculated by using the adddata method of the hash function object Data; Step 104313: Calculate and return the MD5 value of the file to be calculated by md5C=hash.result().toHex(); according to the file data to be calculated.
本实施例中,第一MD5值与第二MD5值是通过动态链接库的更新监听接口的检查回调函数通知主程序的,该动态链接数据库具体为:In this embodiment, the first MD5 value and the second MD5 value are notified to the main program by using a checkback function of the update listener interface of the dynamic link library, and the dynamic link database is specifically:
定义一个IUpdate接口和IListener回调接口,方便外部调用。接口:Define an IUpdate interface and an IListener callback interface for external calls. interface:
Figure PCTCN2017075723-appb-000001
Figure PCTCN2017075723-appb-000001
Figure PCTCN2017075723-appb-000002
Figure PCTCN2017075723-appb-000002
Figure PCTCN2017075723-appb-000003
Figure PCTCN2017075723-appb-000003
由于所有的模块都是通过接口,命令行参数,下载文件进行连接的,可以很好的降低模块与模块之间的耦合度,由此每个模块的更新和修改也是相对独立的。Since all the modules are connected through the interface, command line parameters, and download files, the coupling degree between the modules and the modules can be well reduced, and thus the update and modification of each module is relatively independent.
此外,该在QT程序中自动更新的方法在步骤104和步骤105之间还包括以下步骤:In addition, the method of automatically updating in the QT program further includes the following steps between step 104 and step 105:
步骤z1:获取相邻两次启动更新的时刻T1和T2Step z1: obtaining times T 1 and T 2 of the two adjacent start-ups;
步骤z2:计算相邻两次启动更新的时间差t=|T2-T1|;Step z2: Calculate the time difference t=|T 2 -T 1 |
步骤z3:比较相邻两次启动更新的时间差t与更新阈值t0的大小关系:当t>t0时,启动更新;当t≤t0时,拒绝更新。Step z3: Compare the relationship between the time difference t of the two adjacent start-up updates and the update threshold t 0 : when t>t 0 , the update is initiated; when t≤t 0 , the update is rejected.
在这种情况下,能够避免频繁更新。 In this case, frequent updates can be avoided.
本发明提供的在QT程序中自动更新的方法首先获取更新信息文件;之后,解压缩所述更新信息文件,得到解压缩后的更新信息文件;之后,解析所述解压缩后的更新信息文件,得到经过解析的更新信息文件;之后,通过比较所述经过解析的更新信息文件和对应的本地信息,判断所述对应的本地信息是否需要更新:如需要更新,则启动更新,使得所述更新文件覆盖对应的本地信息;如不需要更新,则维持本地信息。由于其中存在对是否需要更新进行判断的步骤,只有在判断为对应的本地信息需要更新的时候才启动更新,而在判断为对应的本地信息不需要更新的时候则不予更新,因此,能够避免只要主程序启动就进行更新检查造成的频繁验证更新。因此,其能够提高更新效率,降低更新复杂度。The method for automatically updating in the QT program provided by the present invention first obtains an update information file; after that, decompressing the update information file to obtain a decompressed update information file; and then parsing the decompressed update information file, Obtaining the parsed update information file; then, by comparing the parsed update information file and the corresponding local information, determining whether the corresponding local information needs to be updated: if an update is required, starting the update, so that the update file is Overwrite the corresponding local information; if no updates are needed, maintain local information. Since there is a step of judging whether or not an update is required, the update is started only when it is determined that the corresponding local information needs to be updated, and is not updated when it is determined that the corresponding local information does not need to be updated, thereby avoiding A frequent verification update caused by an update check is performed as soon as the main program is started. Therefore, it can improve the update efficiency and reduce the update complexity.
实施例二Embodiment 2
参见附图2,本发明实施例二提供的在QT程序中自动更新的装置包括更新信息文件获取单元201、解压缩单元202、文件解析单元203、比较判断单元204、更新单元205。更新信息文件获取单元201用于获取更新信息文件;解压缩单元202用于解压缩更新信息文件,得到解压缩后的更新信息文件;文件解析单元203用于解析解压缩后的更新信息文件,得到经过解析的更新信息文件;比较判断单元204用于通过比较经过解析的更新信息文件和对应的本地信息,判断对应的本地信息是否需要更新:当比较判断单元204的结果是需要更新时,更新单元205用于根据比较判断单元的判断结果,进行更新,使得更新文件覆盖对应的本地信息;当比较判断单元204的结果是不需要更新时,维持本地信息。Referring to FIG. 2, an apparatus for automatically updating in a QT program according to Embodiment 2 of the present invention includes an update information file obtaining unit 201, a decompressing unit 202, a file parsing unit 203, a comparison judging unit 204, and an updating unit 205. The update information file obtaining unit 201 is configured to obtain an update information file; the decompression unit 202 is configured to decompress the update information file to obtain a decompressed update information file; and the file parsing unit 203 is configured to parse the decompressed update information file to obtain The parsed update information file; the comparison judging unit 204 is configured to judge whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information: when the result of the comparison judging unit 204 needs to be updated, the update unit 205 is configured to update according to the judgment result of the comparison judgment unit, so that the update file covers the corresponding local information; when the result of the comparison judgment unit 204 does not need to be updated, the local information is maintained.
其中,文件解析单元203包括加载模块、错误值判断模块、字段返回模块、 更新回调模块。加载模块用于加载解压缩后的更新信息文件并返回文本对象和错误值;错误值判断模块用于对返回的文本对象和错误值进行判断:当错误值判断模块的判断结果为文本对象不存在错误信息时,字段返回模块通过文本对象返回JSON对象,并采用键值对的形式返回每个字段值,得到经过解析的更新信息文件;当错误值判断模块的判断结果为文本对象存在错误信息时,更新回调模块用于更新错误并回调错误。The file parsing unit 203 includes a loading module, an error value judging module, and a field return module. Update the callback module. The loading module is configured to load the decompressed update information file and return a text object and an error value; the error value judging module is configured to judge the returned text object and the error value: when the error value judging module judges that the text object does not exist In the error message, the field return module returns the JSON object through the text object, and returns each field value in the form of a key-value pair to obtain the parsed update information file; when the error value judgment module determines that the text object has an error message The update callback module is used to update the error and call back the error.
其中,在QT程序中自动更新的装置还包括MD5值计算单元。MD5值计算单元包括散列函数获取模块、文件数据添加模块、MD5值计算返回模块。散列函数获取模块用于获取待计算文件对象的散列函数对象;文件数据添加模块用于应用散列函数对象添加待计算文件数据;MD5值计算返回模块用于根据待计算文件数据计算并返回待计算文件的MD5值。Among them, the device automatically updated in the QT program further includes an MD5 value calculation unit. The MD5 value calculation unit includes a hash function acquisition module, a file data addition module, and an MD5 value calculation return module. The hash function obtaining module is configured to obtain a hash function object of the file object to be calculated; the file data adding module is configured to apply the hash function object to add the to-be-calculated file data; and the MD5 value calculation returning module is configured to calculate and return according to the file data to be calculated. MD5 value of the file to be calculated.
其中,比较判断单元204包括第一比较模块和/或第二比较模块和/或第二比较模块和/或第三比较模块。第一比较模块用于比较第一版本号和第二版本号,当第一版本号与第二版本号不等时,则启动更新;当第一版本号与第二版本号相等时,则维持本地信息。第二比较模块用于比较第一版本号和第三版本号,当第一版本号与第三版本号不等时,则启动更新;当第一版本号与第三版本号相等时,则维持本地信息。第三比较模块用于比较第一MD5值和第二MD5值,若第一MD5值与第二MD5值不等,则启动更新;若第一MD5值与第二MD5值相等,则维持本地信息。其中,第一版本号为本地信息的版本号,第二版本号为经过解析的更新信息文件的版本号,第三版本号为经过解析的更新信息文件的建议版本号。第一MD5值为本地信息的MD5值,第二MD5值为经过解析的更新信息文件的MD5值。 The comparison judging unit 204 includes a first comparison module and/or a second comparison module and/or a second comparison module and/or a third comparison module. The first comparison module is configured to compare the first version number and the second version number. When the first version number and the second version number are not equal, the update is started; when the first version number is equal to the second version number, the first version is maintained. Local information. The second comparison module is configured to compare the first version number and the third version number. When the first version number and the third version number are not equal, the update is started; when the first version number is equal to the third version number, the Local information. The third comparison module is configured to compare the first MD5 value and the second MD5 value, and if the first MD5 value and the second MD5 value are not equal, start an update; if the first MD5 value is equal to the second MD5 value, the local information is maintained. . The first version number is the version number of the local information, the second version number is the version number of the parsed update information file, and the third version number is the suggested version number of the parsed update information file. The first MD5 value is the MD5 value of the local information, and the second MD5 value is the MD5 value of the parsed update information file.
此外,的在QT程序中自动更新的装置还包括更新限制单元。更新限制单元包括更新时刻获取模块、更新时差计算模块、更新时差比较判断模块。更新时刻获取模块用于获取相邻两次启动更新的时刻T1和T2;更新时差计算模块用于计算相邻两次启动更新的时间差t=|T2-T1|;更新时差比较判断模块用于比较相邻两次启动更新的时间差t与更新阈值t0的大小关系,并决定是否启动更新:当t>t0时,启动更新;当t≤t0时,拒绝更新。在这种情况下,能够避免频繁更新。In addition, the device that is automatically updated in the QT program further includes an update restriction unit. The update restriction unit includes an update time acquisition module, an update time difference calculation module, and an update time difference comparison determination module. The update time acquisition module is configured to acquire the times T 1 and T 2 of the two adjacent start updates; the update time difference calculation module is configured to calculate the time difference t=|T 2 -T 1 | of the two adjacent start updates; The module is used to compare the magnitude relationship between the time difference t of the two adjacent start-up updates and the update threshold t 0 , and decide whether to start the update: when t>t 0 , the update is initiated; when t≤t 0 , the update is rejected. In this case, frequent updates can be avoided.
本发明提供的在QT程序中自动更新的装置首先通过更新信息文件获取单元201获取更新信息文件;之后,通过解压缩单元202解压缩所述更新信息文件,得到解压缩后的更新信息文件;之后,通过文件解析单元203解析所述解压缩后的更新信息文件,得到经过解析的更新信息文件;之后,通过比较判断单元204比较所述经过解析的更新信息文件和对应的本地信息,判断所述对应的本地信息是否需要更新:如需要更新,则通过更新单元205启动更新,使得所述更新文件覆盖对应的本地信息;如不需要更新,则维持本地信息。由于其中存在比较判断单元204,只有在判断为对应的本地信息需要更新的时候才触发更新单元启动更新,而在判断为对应的本地信息不需要更新的时候则不会触发更新单元205不予更新,因此,能够避免只要主程序启动就进行更新检查造成的频繁验证更新。因此,其能够提高更新效率,降低更新复杂度。The device automatically updated in the QT program provided by the present invention first obtains the update information file by the update information file obtaining unit 201; after that, the decompressing unit 202 decompresses the update information file to obtain the decompressed update information file; And parsing the decompressed update information file by the file parsing unit 203 to obtain the parsed update information file; and then comparing the parsed update information file and the corresponding local information by the comparison judging unit 204, determining the Whether the corresponding local information needs to be updated: if an update is required, the update is initiated by the update unit 205 so that the update file overwrites the corresponding local information; if no update is required, the local information is maintained. Since the comparison judging unit 204 is present, the update unit is triggered to start the update only when it is determined that the corresponding local information needs to be updated, and the update unit 205 is not triggered to be updated when it is determined that the corresponding local information does not need to be updated. Therefore, it is possible to avoid frequent verification updates caused by the update check as long as the main program is started. Therefore, it can improve the update efficiency and reduce the update complexity.
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。While the preferred embodiment of the invention has been described, it will be understood that Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and the modifications and
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发 明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。 Obviously, those skilled in the art can make various modifications and variations to the present invention without departing from the present invention. The spirit and scope of the Ming. Thus, it is intended that the present invention cover the modifications and modifications of the invention

Claims (10)

  1. 一种在QT程序中自动更新的方法,其特征在于,包括以下步骤:A method for automatically updating in a QT program, comprising the steps of:
    获取更新信息文件;Obtain an update information file;
    通过比较经过解析的所述更新信息文件和对应的本地信息,判断所述对应的本地信息是否需要更新:Determining whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information:
    如需要更新,则启动更新,使得所述更新文件覆盖对应的本地信息;If an update is required, an update is initiated such that the update file overwrites corresponding local information;
    如不需要更新,则维持所述本地信息。If the update is not required, the local information is maintained.
  2. 根据权利要求1所述的在QT程序中自动更新的方法,其特征在于,所述解析所述更新信息文件,得到经过解析的更新信息文件包括以下步骤:The method of automatically updating in a QT program according to claim 1, wherein the parsing the update information file to obtain the parsed update information file comprises the following steps:
    加载所述更新信息文件并返回文本对象和错误值;Loading the update information file and returning text objects and error values;
    对所述返回的文本对象和错误值进行判断:Judge the returned text object and the error value:
    若所述文本对象不存在错误信息,则通过文本对象返回JSON对象,并采用键值对的形式返回每个字段值,得到所述经过解析的更新信息文件;If the text object does not have an error message, returning the JSON object through the text object, and returning each field value in the form of a key-value pair to obtain the parsed update information file;
    若所述文本对象存在错误信息,则更新错误并回调所述错误。If the text object has an error message, the error is updated and the error is recalled.
  3. 根据权利要求1所述的在QT程序中自动更新的方法,定义本地信息的版本号为第一版本号,定义所述经过解析的更新信息文件的版本号为第二版本号,定义所述经过解析的更新信息文件的建议版本号为第三版本号;The method of automatically updating in a QT program according to claim 1, wherein the version number of the local information is defined as a first version number, and the version number of the parsed update information file is defined as a second version number, and the The suggested version number of the parsed update information file is the third version number;
    其特征在于,It is characterized in that
    所述通过比较所述经过解析的更新信息文件和对应的本地信息,判断所述对应的本地信息是否需要更新包括以下步骤:The comparing, by comparing the parsed update information file and the corresponding local information, determining whether the corresponding local information needs to be updated includes the following steps:
    比较所述第一版本号的字符串与所述第二版本号的字符串:Comparing the string of the first version number with the string of the second version number:
    若所述第一版本号的字符串与所述第二版本号的字符串不等,则启动更 新;If the character string of the first version number is not equal to the character string of the second version number, start more new;
    若所述第一版本号的字符串与所述第二版本号的字符串相等,则维持所述本地信息;If the character string of the first version number is equal to the character string of the second version number, maintaining the local information;
    和/或,and / or,
    比较所述第一版本号的字符串与所述第三版本号的字符串:Comparing the string of the first version number with the string of the third version number:
    若所述第一版本号的字符串与所述第三版本号的字符串不等,则启动更新;If the character string of the first version number is not equal to the character string of the third version number, starting an update;
    若所述第一版本号的字符串与所述第三版本号的字符串相等,则维持所述本地信息;If the character string of the first version number is equal to the character string of the third version number, maintaining the local information;
    和/或,and / or,
    计算本地信息的MD5值并得到第一MD5值,计算所述经过解析的更新信息文件的MD5值并得到第二MD5值:Calculating the MD5 value of the local information and obtaining the first MD5 value, calculating the MD5 value of the parsed update information file and obtaining the second MD5 value:
    若所述第一MD5值与所述第二MD5值不等,则启动更新;If the first MD5 value is not equal to the second MD5 value, starting an update;
    若所述第一MD5值与所述第二MD5值相等,则维持所述本地信息。If the first MD5 value is equal to the second MD5 value, the local information is maintained.
  4. 根据权利要求3所述的在QT程序中自动更新的方法,其特征在于,所述MD5值的计算方法包括以下步骤:The method for automatically updating in a QT program according to claim 3, wherein the method for calculating the MD5 value comprises the following steps:
    获取待计算文件对象的散列函数对象;Obtaining a hash function object of the file object to be calculated;
    应用所述散列函数对象添加待计算文件数据;Applying the hash function object to add file data to be calculated;
    根据所述待计算文件数据计算并返回所述待计算文件的MD5值;Calculating and returning an MD5 value of the file to be calculated according to the file data to be calculated;
    其中,所述第一MD5值与所述第二MD5值是通过动态链接库的更新监听接口的检查回调函数通知主程序的。The first MD5 value and the second MD5 value are notified to the main program by a checkback function of the update listener interface of the dynamic link library.
  5. 根据权利要求1所述的在QT程序中自动更新的方法,其特征在于,还 包括以下步骤:A method of automatically updating in a QT program according to claim 1, further comprising Includes the following steps:
    获取相邻两次启动更新的时刻T1和T2Obtaining times T 1 and T 2 of two adjacent start-up updates;
    计算所述相邻两次启动更新的时间差t=|T2-T1|;Calculating a time difference t=|T 2 -T 1 | of the two adjacent startup updates;
    比较相邻两次启动更新的时间差t与更新阈值t0的大小关系:Compare the relationship between the time difference t of the two adjacent start-up updates and the update threshold t 0 :
    当t>t0时,启动更新;When t>t 0 , the update is started;
    当t≤t0时,拒绝更新。When t ≤ t 0 , the update is rejected.
  6. 一种在QT程序中自动更新的装置,其特征在于,包括更新信息文件获取单元、比较判断单元、更新单元,An apparatus for automatically updating in a QT program, comprising: an update information file acquisition unit, a comparison determination unit, and an update unit,
    所述更新信息文件获取单元用于获取更新信息文件;The update information file obtaining unit is configured to acquire an update information file;
    所述比较判断单元用于通过比较经过解析的所述更新信息文件和对应的本地信息,判断所述对应的本地信息是否需要更新:The comparison determining unit is configured to determine whether the corresponding local information needs to be updated by comparing the parsed update information file and the corresponding local information:
    当所述比较判断单元的结果是需要更新时,所述更新单元用于根据所述比较判断单元的判断结果,进行更新,使得所述更新文件覆盖对应的本地信息;When the result of the comparison determination unit is that the update is required, the update unit is configured to perform an update according to the determination result of the comparison determination unit, so that the update file covers the corresponding local information;
    当所述比较判断单元的结果是不需要更新时,维持所述本地信息。The local information is maintained when the result of the comparison judging unit is that no update is required.
  7. 根据权利要求6所述的在QT程序中自动更新的装置,其特征在于,所述文件解析单元包括加载模块、错误值判断模块、字段返回模块、更新回调模块,The apparatus for automatically updating in a QT program according to claim 6, wherein the file parsing unit comprises a loading module, an error value judging module, a field returning module, and an update callback module.
    所述加载模块用于加载所述更新信息文件并返回文本对象和错误值;The loading module is configured to load the update information file and return a text object and an error value;
    所述错误值判断模块用于对所述返回的文本对象和错误值进行判断:The error value judging module is configured to judge the returned text object and an error value:
    当所述错误值判断模块的判断结果为所述文本对象不存在错误信息时,所述字段返回模块通过文本对象返回JSON对象,并采用键值对的形式返回每个字段值,得到所述经过解析的更新信息文件; When the judgment result of the error value judgment module is that the text object does not have error information, the field return module returns a JSON object through the text object, and returns each field value in the form of a key value pair to obtain the Parsed update information file;
    当所述错误值判断模块的判断结果为所述文本对象存在错误信息时,所述更新回调模块用于更新错误并回调所述错误。When the judgment result of the error value judgment module is that the text object has error information, the update callback module is used to update the error and call back the error.
  8. 根据权利要求6所述的在QT程序中自动更新的装置,其特征在于,还包括MD5值计算单元,The apparatus for automatically updating in a QT program according to claim 6, further comprising an MD5 value calculation unit,
    所述MD5值计算单元包括散列函数获取模块、文件数据添加模块、MD5值计算返回模块,The MD5 value calculation unit includes a hash function acquisition module, a file data addition module, and an MD5 value calculation return module.
    所述散列函数获取模块用于获取待计算文件对象的散列函数对象;The hash function obtaining module is configured to obtain a hash function object of the file object to be calculated;
    所述文件数据添加模块用于应用所述散列函数对象添加待计算文件数据;The file data adding module is configured to apply the hash function object to add file data to be calculated;
    所述MD5值计算返回模块用于根据所述待计算文件数据计算并返回所述待计算文件的MD5值。The MD5 value calculation returning module is configured to calculate and return an MD5 value of the file to be calculated according to the file data to be calculated.
  9. 根据权利要求6所述的在QT程序中自动更新的装置,其特征在于,所述比较判断单元包括第一比较模块和/或第二比较模块和/或第二比较模块和/或第三比较模块,The apparatus for automatically updating in a QT program according to claim 6, wherein the comparison judging unit comprises a first comparison module and/or a second comparison module and/or a second comparison module and/or a third comparison. Module,
    所述第一比较模块用于比较第一版本号和第二版本号,当所述第一版本号与所述第二版本号不等时,则启动更新;当所述第一版本号与所述第二版本号相等时,则维持所述本地信息;The first comparison module is configured to compare the first version number and the second version number, and when the first version number and the second version number are not equal, start an update; when the first version number and the When the second version numbers are equal, the local information is maintained;
    所述第二比较模块用于比较第一版本号和第三版本号,当所述第一版本号与所述第三版本号不等时,则启动更新;当所述第一版本号与所述第三版本号相等时,则维持所述本地信息;The second comparison module is configured to compare the first version number and the third version number, and when the first version number and the third version number are not equal, start an update; when the first version number and the When the third version number is equal, the local information is maintained;
    所述第三比较模块用于比较第一MD5值和第二MD5值,若所述第一MD5值与所述第二MD5值不等,则启动更新;若所述第一MD5值与所述第二MD5值相等,则维持所述本地信息; The third comparison module is configured to compare the first MD5 value and the second MD5 value, if the first MD5 value is not equal to the second MD5 value, initiate an update; if the first MD5 value is If the second MD5 values are equal, the local information is maintained;
    其中,among them,
    所述第一版本号为本地信息的版本号,所述第二版本号为经过解析的更新信息文件的版本号,所述第三版本号为经过解析的更新信息文件的建议版本号;The first version number is a version number of the local information, the second version number is a version number of the parsed update information file, and the third version number is a suggested version number of the parsed update information file;
    所述第一MD5值为本地信息的MD5值,所述第二MD5值为经过解析的更新信息文件的MD5值。The first MD5 value is an MD5 value of local information, and the second MD5 value is an MD5 value of the parsed update information file.
  10. 根据权利要求6所述的在QT程序中自动更新的装置,其特征在于,还包括更新限制单元,The apparatus for automatically updating in a QT program according to claim 6, further comprising an update restriction unit,
    所述更新限制单元包括更新时刻获取模块、更新时差计算模块、更新时差比较判断模块,The update restriction unit includes an update time acquisition module, an update time difference calculation module, and an update time difference comparison determination module.
    所述更新时刻获取模块用于获取相邻两次启动更新的时刻T1和T2The update time acquisition module is configured to acquire times T 1 and T 2 when the update is initiated twice;
    所述更新时差计算模块用于计算所述相邻两次启动更新的时间差t=|T2-T1|;The update time difference calculation module is configured to calculate a time difference t=|T 2 -T 1 | of the two adjacent startup updates;
    所述更新时差比较判断模块用于比较相邻两次启动更新的时间差t与更新阈值t0的大小关系,并决定是否启动更新:The update time difference comparison judging module is configured to compare the size relationship between the time difference t and the update threshold t 0 of the two adjacent start updates, and decide whether to start the update:
    当t>t0时,启动更新;When t>t 0 , the update is started;
    当t≤t0时,拒绝更新。 When t ≤ t 0 , the update is rejected.
PCT/CN2017/075723 2016-12-01 2017-03-06 Automatic update method and device for qt program WO2018098919A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201611092244.2 2016-12-01
CN201611092244.2A CN106648761B (en) 2016-12-01 2016-12-01 The method and device automatically updated in QT program

Publications (1)

Publication Number Publication Date
WO2018098919A1 true WO2018098919A1 (en) 2018-06-07

Family

ID=58814681

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/075723 WO2018098919A1 (en) 2016-12-01 2017-03-06 Automatic update method and device for qt program

Country Status (2)

Country Link
CN (1) CN106648761B (en)
WO (1) WO2018098919A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114745268A (en) * 2022-03-31 2022-07-12 杭州视洞科技有限公司 Method for online updating and loading algorithm library of network camera

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108845824A (en) * 2018-07-10 2018-11-20 平安科技(深圳)有限公司 Using update method and device and computer readable storage medium
CN109413115B (en) * 2018-12-29 2021-08-20 中国银行股份有限公司 Protocol text analysis method and system
CN111831296A (en) * 2019-04-17 2020-10-27 天津五八到家科技有限公司 Application program updating method, terminal device and computer-readable storage medium
CN111191422B (en) * 2019-12-31 2023-09-05 湖南中联重科智能技术有限公司 File format conversion method, device and computer readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100077387A1 (en) * 2008-09-25 2010-03-25 Microsoft Corporation Managing updates using compiler and linker information
CN101977217A (en) * 2010-10-15 2011-02-16 中兴通讯股份有限公司 Widget updating method and system as well as Widget client and Widget server
CN102546246A (en) * 2011-12-28 2012-07-04 创新科存储技术(深圳)有限公司 Method and system for automatic upgrade of software
CN104539696A (en) * 2014-12-26 2015-04-22 北京像素软件科技股份有限公司 Client end incremental updating method and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104391729B (en) * 2014-12-19 2018-05-01 北京奇虎科技有限公司 Programme upgrade method and device based on Root authority

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100077387A1 (en) * 2008-09-25 2010-03-25 Microsoft Corporation Managing updates using compiler and linker information
CN101977217A (en) * 2010-10-15 2011-02-16 中兴通讯股份有限公司 Widget updating method and system as well as Widget client and Widget server
CN102546246A (en) * 2011-12-28 2012-07-04 创新科存储技术(深圳)有限公司 Method and system for automatic upgrade of software
CN104539696A (en) * 2014-12-26 2015-04-22 北京像素软件科技股份有限公司 Client end incremental updating method and system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114745268A (en) * 2022-03-31 2022-07-12 杭州视洞科技有限公司 Method for online updating and loading algorithm library of network camera

Also Published As

Publication number Publication date
CN106648761B (en) 2019-04-05
CN106648761A (en) 2017-05-10

Similar Documents

Publication Publication Date Title
WO2018098919A1 (en) Automatic update method and device for qt program
US9317508B2 (en) Pro-active self-healing in a distributed file system
US8239662B1 (en) Network based operating system across devices
WO2015074467A1 (en) Data update method, apparatus, and system and storage medium
CN107992537B (en) Service attribute transmission method, device, computer equipment and storage medium
US9678767B2 (en) Unified extensible firmware interface (UEFI) driver and protocol
KR20150110532A (en) Peer-to-peer software updates
US9910733B2 (en) Transaction completion in a synchronous replication environment
EP4049130B1 (en) Updating a metadata structure for a firmware update
US11816458B2 (en) Method and system for packaging infrastructure as code
CN110362338B (en) Game resource packaging and resource quick access method under mobile platform
WO2020010727A1 (en) Application update method and device, and computer readable storage medium
WO2020113947A1 (en) Network file deletion method and device, computer device and storage medium
CN108628733B (en) Method and device for testing batch service processing operation
WO2018000500A1 (en) Application program management method, management apparatus, and mobile terminal
CN106776131B (en) Data backup method and server
CN114640709B (en) Edge node processing method, device and medium
WO2019000897A1 (en) Data acquisition method and device
CN112559344A (en) Remote mock testing method and system
US10795747B2 (en) File synchronizing service status monitoring and error handling
WO2017045473A1 (en) Business process operation method and apparatus
WO2016173122A1 (en) Network search method and device
CN109298880B (en) Multi-version code generation method and device and electronic device
CN112565472A (en) Static resource processing method and device
CN110502351A (en) Based on the asynchronous loading method of Unity Internet resources and system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17877129

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17877129

Country of ref document: EP

Kind code of ref document: A1