Each application program is used the method for unified download interface under a kind of WINCE
Technical field
The present invention relates to the embedded product field of software development, each application program is used the method for unified download interface under particularly a kind of WINCE.
Background technology
The download function of existing each application software of WINCE all is to call download api function separately to realize download function; Each application program all need repeat to write download code separately; Safeguard processing such as downloading time-out, continuation, success, failure, code redundancy is high, is unfavorable for safeguarding.
Along with popularizing of Internet development and WINCE terminal, application program is more and more heavier to the dependence of network, again because independent mutually between the software of each application program; All need write network data and download this section code, all need call a series of system interface functions (like AfxParseURL, GetHttpConnection; OpenRequest, SendRequest, QueryInfoStatusCode; Read, Close or the like), accomplish the function that data are downloaded.In addition, because network formats is inequality, CDMA is arranged at present; GSM; Network formats such as CDMA2000, WCDMA, TD-SCDMA, the module that the WINCE terminal of different network formats connects is different, and the data download process also can be different; Need bring in constant renewal in code for each application program of compatible disparate modules and satisfy the demands, maintenance cost is high.If adopt unified download interface handling procedure; Then each application program need not to be concerned about which type of network formats the WINCE terminal adopts; Dispose which type of hardware module; The convenient transplanting and code reuse makes things convenient for the misarrangement and the debugging of program, can improve the development efficiency of application program and the stability of program.
Summary of the invention
Need repeat to write the technical problem of downloading code in order to solve existing WINCE application software for realizing downloads, the present invention provides each application program under the strong WINCE of succinct convenience and extensibility to use the method for unification download interface.
In order to realize above-mentioned technical purpose, technical scheme of the present invention is that each application program is used the method for unified download interface under a kind of WINCE, may further comprise the steps:
Each application program is used the method for unified download interface under a kind of WINCE, may further comprise the steps:
Steps A: set up a download process module that is used to handle each application program download request on the backstage;
Step B: each application program unification is sent to the download process module with download request, download process resume module download request, and disposition fed back to each application program;
Step C: the download process module will respond download request and download successful data and be kept in the local directory with the form of file, directly handled by the application program of proposition download request.
Described method, the download process module described in the steps A comprises download request receiving element, download unit and download state feedback unit.
Described method; The download process module is accepted the downloading request message that each application program sends over through the download request receiving element and is stored among the step B, then the data parameters that is comprised in the downloading request message is carried out dissection process to judge whether being effective download request.
Described method, described download request receiving element stores the mode of downloading request message with formation by the order that receives, and according to the order of first in first out the data parameters that downloading request message comprised in the formation is carried out dissection process then.
Described method, described data parameters comprises window handle, downloads id, url, four parameters of belt paths long filenames.
Described method, describedly the data parameter is carried out dissection process comprise:
1) whether inspection handle parameter greater than zero, meets the requirements greater than zero, undesirable smaller or equal to zero;
2) inspection download the id parameter whether greater than zero and not with the download request that has existed in id repeat; Greater than zero and not with the download request that has existed in id repeat then to meet the requirements, smaller or equal to zero or repeat then undesirable with id in the download request that has existed;
3) whether inspection url parameter meets the requirement of RFC2616 protocol specification, meets the RFC2616 protocol specification and then meets the requirements, and it is then undesirable not meet the RFC2616 protocol specification;
4) whether the path in the inspection belt paths long filenames parameter exists, and the path existence then meets the requirements, and the path does not exist then undesirable;
Above-mentioned four inspections are if wherein have at least one association parameter undesirable; Then the download request receiving element is judged as invalid downloading request message with this downloading request message; If four association parameters all meet the requirements, then the download request receiving element is judged as effective downloading request message with this downloading request message.
Described method; The download request receiving element will be judged as effective downloading request message and be sent to download unit; Download module carries out data download according to effective downloading request message, and the download status information that will download success or failed download according to the download situation then is sent to the download state feedback unit.
Described method, download request receiving element are judged as download state message to the download state feedback unit that invalid downloading request message is then directly sent invalid download.
Described method, download state feedback unit feed back to the download status information that is received the application program of sending download request information.
Technique effect of the present invention is that code is succinct, need not each application program and writes a large amount of download process codes; Maintainable high, if download process changes or adds new function, only need to revise the download center handling procedure.Highly versatile only needs the several macrodefinitions of simple statement just can directly use unified download interface.
Below in conjunction with accompanying drawing the present invention is described further.
Description of drawings
Fig. 1 is a structural representation of the present invention;
Fig. 2 is a handling process sketch map of the present invention.
Embodiment
The present invention includes following steps:
Steps A: set up a download process module that is used to handle each application program download request on the backstage, the download process module comprises download request receiving element, download unit and download state feedback unit.
Step B: each application program unification is sent to the download process module with download request, download process resume module download request, and disposition fed back to each application program.Concrete processing procedure does; The download process module is accepted the downloading request message that each application program sends over through the download request receiving element and is stored; Then the data parameters that is comprised in the downloading request message is carried out dissection process to judge whether being effective download request; If successively receive a plurality of download requests; Then the download request receiving element stores the mode of downloading request message with formation by the order that receives, and according to the order of first in first out the data parameters that downloading request message comprised in the formation is carried out dissection process then.Data parameters comprises window handle, downloads id, url, and four parameters of belt paths long filenames, concrete parameter are resolved to handle and are comprised:
1) whether inspection handle parameter greater than zero, meets the requirements greater than zero, undesirable smaller or equal to zero;
2) inspection download the id parameter whether greater than zero and not with the download request that has existed in id repeat; Greater than zero and not with the download request that has existed in id repeat then to meet the requirements, smaller or equal to zero or repeat then undesirable with id in the download request that has existed;
3) whether inspection url parameter meets the requirement of RFC2616 protocol specification, meets the RFC2616 protocol specification and then meets the requirements, and it is then undesirable not meet the RFC2616 protocol specification;
4) whether the path in the inspection belt paths long filenames parameter exists, and the path existence then meets the requirements, and the path does not exist then undesirable;
Above-mentioned four inspections of carrying out; If wherein have at least one association parameter undesirable; Then the download request receiving element is judged as invalid downloading request message with this downloading request message; If four association parameters all meet the requirements, then the download request receiving element is judged as effective downloading request message with this downloading request message.
The download request receiving element will be judged as effective downloading request message and be sent to download unit; Download module carries out data download according to effective downloading request message, and the download status information that will download success or failed download according to the download situation then is sent to the download state feedback unit.
The download request receiving element is judged as download state message to the download state feedback unit that invalid downloading request message is then directly sent invalid download.
Step C: the download process module will respond download request and download successful data and be kept in the local directory with the form of file, directly handled by the application program of proposition download request.
When reality was used, each application program only need comprise several macrodefinitions can call unified download interface completion download.