Summary of the invention
In view of this, the object of the present invention is to provide method and the client of a kind of off-line operation Widget, solve in the time that network state is bad, because Widget cannot load important network data in time, and the problem that cannot normally show, even cannot normally use, and then, the convenience of guarantee Widget.
For achieving the above object, technical scheme of the present invention is achieved in that
A kind of method that the invention provides off-line operation Widget, the method comprises:
In the time that network state is good, client is obtained after the required network data of Widget, in the time containing universal resource identifier corresponding to network data (URI, Universal ResourcesIdentifier) address in the list of confirmation caching resource, preserve this network data;
In the time that network state is bad, described client is confirmed self to have deposited after the required network data of Widget according to caching resource list, obtains network data from self.
In such scheme, before this network data of described preservation, the method also comprises: client query URI address whether in caching resource list, if, preserve network data; Otherwise client is used the network data operation Widget obtaining.
In such scheme, before the required network data of Widget has been deposited in described confirmation self, the method also comprises: whether client query URI address is in caching resource list, if do not existed, client interconnection network, obtains network data; If, check and self whether have the corresponding local file in URI address, if had, from self obtaining the required network data of Widget; If no, client interconnection network, obtains network data.
In such scheme, described caching resource list, for: client is resolved the configuration file of preset caching resource list, the caching resource list of generation.
In such scheme, described network state, for: whether client, detecting in any one Widget running in real time, needs to obtain network data, if needed, detects current network state; If do not needed,, in any one Widget running of duplicate detection, whether need to obtain network data.
The present invention also provides the client of a kind of off-line operation Widget, and this client comprises: Widget operation module, buffer memory URI enquiry module, child resource cache module, child resource download module and cache list parsing module; Wherein,
Widget moves module, when good for network state, from child resource download module obtains the required network data of Widget, while receiving the Query Result that contains URI address corresponding to network data in the confirmation caching resource list that buffer memory URI enquiry module sends, this network data is sent to child resource cache module; In the time that network state is bad, receive after the Query Result that contains URI address corresponding to network data in the confirmation caching resource list that buffer memory URI enquiry module sends, obtain network data from child resource cache module;
Buffer memory URI enquiry module, is used to Widget operation module to return to the Query Result that contains corresponding URI address in the caching resource list of confirming cache list parsing module;
Child resource cache module, the network data of sending for receiving and preserve Widget operation module, and provide network data for Widget moves module;
Cache list parsing module, is used to buffer memory URI enquiry module that caching resource list is provided;
Child resource download module, is used to Widget operation module that the required network data of Widget is provided.
In such scheme,
Described Widget operation module, specifically for receiving the whether Query Result in caching resource list of URI address that buffer memory URI enquiry module returns, if, network data is sent to child resource cache module, otherwise, use the network data operation Widget obtaining;
Accordingly, described buffer memory URI enquiry module, specifically for sending the whether Query Result in caching resource list of URI address for Widget operation module;
Described child resource cache module, the network data of sending specifically for receiving and preserve Widget operation module.
In such scheme,
Described Widget operation module, specifically for receiving the whether Query Result in caching resource list of URI address that buffer memory URI enquiry module returns, if do not existed, notify child resource download module interconnection network, if, check in child resource cache module whether have the corresponding local file in URI address, if had, obtain the required network data of Widget from child resource cache module; If no, notify child resource download module interconnection network;
Accordingly, described child resource download module, the notice of the interconnection network of sending specifically for reception Widget operation module is obtained network data from network;
Described child resource cache module, specifically for providing the network data of having deposited for Widget operation module.
In such scheme,
Described cache list parsing module, also, for the configuration file of resolving resource cache list, generates caching resource list.
In such scheme, described client, also comprises: network strategy enquiry module, for receiving after the notice of the detection current network state that Widget operation module sends, starts Sampling network state;
Accordingly, whether described Widget operation module, also, for detecting in real time any one Widget running, need to obtain network data, if needed, informing network policy lookup module detects current network state; If do not needed,, in any one Widget running of duplicate detection, whether need to obtain network data.
The method of off-line operation Widget provided by the present invention and client, there is following advantage and disadvantage: the present invention passes through according to the URI address in caching resource list, determine the network data of required buffer memory, in the time that network state is bad, if the URI address of the required network data of Widget is in caching resource list, can directly from client self buffer memory, directly extract network data, thereby solve because Widget cannot load important network data in time, and cannot normally show, the problem that even cannot normally use, and then, ensure the convenience of Widget.
Embodiment
Basic thought of the present invention is: in the time that network state is good, client is obtained after the required network data of Widget, in the time confirming to contain in caching resource list URI address corresponding to network data, preserves this network data; In the time that network state is bad, this client is confirmed self to have deposited after the required network data of Widget according to caching resource list, obtains network data from self.
Wherein, described caching resource list, for: the corresponding URI address list of network data that needs preservation;
Good and the described network state of described network state is bad, can be for using network signal intensity to judge, and concrete decision method is prior art, does not repeat here.
Below in conjunction with drawings and the specific embodiments, the present invention is further described in more detail.
The method of off-line operation Widget of the present invention as shown in Figure 1, comprises lower step:
Step 101: client detects in any one Widget running in real time, judges whether to obtain network data, if needed, performs step 102; If do not needed, repeated execution of steps 101.
Here, describedly whether need to obtain network data, while operation according to Widget, whether send the data acquisition information that contains URI and judge, if send the data acquisition information that contains URI, for need to obtain network data; If do not send the data acquisition information that contains URI, for not needing to obtain network data;
Wherein, described in contain URI data acquisition information, can comprise URI address and Widget mark, production method is prior art, does not repeat here.
Step 102: client detects current network state, if network state is bad, performs step 106; If network state is good, perform step 103.
Here, described detection current network state, can be for being used network signal intensity to judge, concrete decision method is prior art, does not repeat here.
Step 103: client interconnection network, obtains network data.
Here, described interconnection network, obtains network data, for using prior art to realize, can comprise: client is according to the URI address in the data acquisition information that contains URI, from network data corresponding to Network Capture;
Wherein, described interconnection network, when current network state is bad, client is attempted in real time interconnection network, is obtained network data, until receive this network data completely, stops interconnection network; When current network state is good, client directly according to URI address from network data corresponding to Network Capture.
Step 104: client query URI address whether in caching resource list, if, perform step 105; Otherwise client is directly used the network data operation Widget obtaining.
Here, described client is directly used the network data operation Widget obtaining, for prior art, client is directly used network data, complete the subsequent operation of the Widget that sends this data acquisition information that contains URI, and for non-existent URI address in caching resource list, client does not need to preserve the network data of obtaining.
Step 105: client storage network data, is used the network data operation Widget obtaining, end process flow process.
This step is specially: whether client query self has network data corresponding to this URI address, if do not had,, for this network data creates corresponding local file, network data is kept in this local file, then client is used the network data operation Widget obtaining; If had, former network data is updated to the network data of new reception, then client is used the network data operation Widget obtaining;
Here, the local file that described establishment is corresponding, the mode of establishment is prior art, does not repeat here; Described local file, its title can be: the mark of Widget and URI address.
Step 106: whether client query URI address in caching resource list, if do not existed, performs step 103; If, perform step 107.
Step 107: client checks self whether there is the corresponding local file in URI address, if had, from self obtaining the required network data of Widget; If no, perform step 103.
Here, described in check, Ke Yiwei: inquiry local file title in whether comprise this URI address, if comprised, self have the corresponding local file in URI address; If do not comprised, self do not preserve the corresponding local file in URI address;
Described from self obtaining the required network data of Widget, for: according to the mark of Widget and URI address, in the local file of preserving in client self, find the file name identical with URI address with the mark of Widget, then extract the network data of preserving in this local file, client utilizes network data to complete the subsequent operation of this Widget according to prior art.
In addition, carry out before above-mentioned steps 101, need to be in client resource allocation cache list, specifically comprise:
Step a: the configuration file of preset caching resource list in client.
Here describedly, presetly can be: the developer of Widget is in the time issuing any one Widget, and the configuration file of preset caching resource list in the configuration file of Widget installation kit, will need the URI address preparation of buffer memory in configuration file; Its compiling form can be extend markup language (XML, extensiblemarkup language) form, such as: <cache-manifest uri=" http://test/policy.xml " ></cache-manifestGreatT.GreaT .GT, represents that needing the URI address of buffer memory is http://test/policy.xml;
Also can be: the configuration file of client developer's preset caching resource list in client,, will need the URI address preparation of buffer memory in configuration file; Its compiling form can be XML form, as shown in Figure 2, wherein </cache-manifest> represents to need the content of buffer memory, <uri>http: //test/policy.xml</uri> represents that URI address is http://test/policy.xml, <uri>http: //test/logo.jpg</uri> represents that URI address is http://test/logo.jpg.
Step b: the configuration file of client resolving resource cache list, generates caching resource list.
Step b can be: in the time that the configuration file of preset caching resource list is in the configuration file of Widget installation kit, when client is moved this Widget installation kit, according to the configuration file of preset caching resource list, generate caching resource list;
Step b can also be: in the time of the configuration file of client developer preset caching resource list in client, client, in the time of first operation, according to the configuration file of preset caching resource list, generates caching resource list.
Here, described according to the configuration file of preset caching resource list, generate caching resource list, it specifically generates method, is prior art, does not repeat here.
The present invention also provides the client of a kind of off-line operation Widget, and as shown in Figure 3, this client comprises: Widget operation module 21, buffer memory URI enquiry module 22, child resource cache module 23, cache list parsing module 24 and child resource download module 25; Wherein,
Widget moves module 21, when good for network state, from child resource download module 25 obtains the required network data of Widget, while receiving the Query Result that contains URI address corresponding to network data in the confirmation caching resource list that buffer memory URI enquiry module 22 sends, this network data is sent to child resource cache module 23; In the time that network state is bad, receive after the Query Result that contains URI address corresponding to network data in the confirmation caching resource list that buffer memory URI enquiry module 22 sends, obtain network data from child resource cache module 23;
Buffer memory URI enquiry module 22, is used to Widget operation module 21 to return to the Query Result that contains corresponding URI address in the caching resource list of confirming cache list parsing module 24;
Child resource cache module 23, the network data of sending for receiving and preserve Widget operation module 21, and provide network data for Widget moves module 21;
Cache list parsing module 24, is used to buffer memory URI enquiry module 22 that caching resource list is provided;
Child resource download module 25, is used to Widget operation module 21 that the required network data of Widget is provided.
Described client, also comprises: network strategy enquiry module 26, for receiving after the notice of the detection current network state that Widget operation module 21 sends, starts Sampling network state; Accordingly, whether described Widget operation module 21, also, for detecting in real time any one Widget running, need to obtain network data, if needed, informing network policy lookup module 26 detects current network state; If do not needed,, in any one Widget running of duplicate detection, whether need to obtain network data.
Described Widget operation module 21, when moving according to Widget, judges whether to obtain network data by whether sending the data acquisition information that contains URI, if send the data acquisition information that contains URI, for need to obtain network data; If do not send the data acquisition information that contains URI, for not needing to obtain network data.
Described network strategy enquiry module 26, specifically for detecting current network state, for Widget operation module 21 is returned to network state information; Accordingly, described Widget operation module 21, the network state information of sending specifically for receiving network strategy enquiry module 26, when network state information is that network state is when good, the data acquisition information that contains URI is sent to child resource download module 25 and notifies child resource download module 25 to obtain network data, receive the network data that child resource download module 25 returns; Described child resource download module 25, the data acquisition information that contains URI of sending specifically for receiving Widget operation module 21, with obtain after the notice of network data, interconnection network, obtain network data, network data is returned to Widget operation module 21 together with Widget mark and the URI address of this network data;
Here, described child resource download module 25, specifically for using prior art to realize interconnection network, obtains network data, can comprise: according to the URI address in the data acquisition information that contains URI, from network data corresponding to Network Capture.
Described Widget operation module 21, specifically for the URI address of the Internet resources that obtain being sent to buffer memory URI enquiry module 22, notice buffer memory URI enquiry module 22 inquire about this URI address whether in caching resource list, and receive the Query Result that buffer memory URI enquiry module 22 returns; Accordingly, described buffer memory URI enquiry module 22, whether the URI address of sending specifically for receiving Widget operation module 21, have this URI address in the caching resource list in query caching list parsing module 24, and Query Result is returned to Widget operation module 21.
Described Widget operation module 21, specifically for being in caching resource list time when Query Result, this network data sends to child resource cache module 23 together with Widget mark and the URI address of this network data, uses the network data operation Widget obtaining simultaneously; Otherwise, directly use the network data operation Widget obtaining;
Accordingly, described child resource cache module 23, the network data of sending specifically for reception Widget operation module 21 is together with Widget mark and the URI address of this network data, whether inquiry has network data corresponding to this URI address, if no, utilize the URI address of this network data and Widget mark to create corresponding local file, network data is kept in the local file of new establishment, if had, former network data is updated to the network data of new reception.
Described Widget operation module 21, the network state information of sending specifically for receiving network strategy enquiry module 26, when network state information is that network state is when bad, URI address in the data acquisition information that contains URI is sent to buffer memory URI enquiry module 22, and receive the Query Result that buffer memory URI enquiry module 22 returns; Accordingly, described buffer memory URI enquiry module 22, the URI address of sending specifically for receiving Widget operation module 21, inquires about this URI address whether in the caching resource list in cache list parsing module 24, and Query Result is returned to Widget operation module 21.
Described Widget operation module 21, specifically for when Query Result is not in caching resource list time, sends to the data acquisition information that contains URI child resource download module 25 and notifies child resource download module 25 to obtain network data; When Query Result is in caching resource list time, check whether child resource cache module 23 has the corresponding local file of mark and URI address of Widget, if had, obtain the required local file of Widget from child resource cache module 23, then extract the network data of preserving in this local file, utilize network data to complete the subsequent operation of this Widget according to prior art; If no, the data acquisition information that contains URI is sent to child resource download module 25 and notifies child resource download module 25 to obtain network data;
Here, described in check, Ke Yiwei: whether comprise the URI address of these required Internet resources in the title of the local file in inquiry child resource cache module 23, if comprised, have the corresponding local file in URI address; If do not comprised, do not preserve the corresponding local file in URI address.
Described cache list parsing module 24, also for the configuration file of resolving resource cache list, preserves the final caching resource list generating;
Be specifically as follows: in the time that the configuration file of preset caching resource list is in the configuration file of Widget installation kit, when Widget operation module 21 this Widget installation kit of operation, the configuration file of the caching resource list in Widget installation kit is sent to cache list parsing module 24; Described cache list parsing module 24, the configuration file of the caching resource list that parsing Widget operation module 21 is sent, generates caching resource list;
Also can be: the configuration file of client developer's preset caching resource list in cache list parsing module 24, client is in the time of first operation, according to the configuration file of caching resource list preset in cache list parsing module 24, generate caching resource list.
Client described in such scheme, can be used as integration module, is arranged in equipment according to actual conditions, such as, can be arranged in mobile phone.
The above, be only preferred embodiment of the present invention, is not intended to limit protection scope of the present invention.