11 Replies Last post: Jun 27, 2008 1:47 PM by BobM

Need more details on OCC

Jun 17, 2008 9:34 PM

Click to view URPradhan's profile Level 6 URPradhan 108 posts since
Mar 6, 2008
Hi Friends

OCC, as the name suggests it gives the flexibility to run curl applets in offline mode. And my understanding from the documentation is that, an OCC enabled application makes a copy of its source code tree on client's machine in user's application directory along with a small amount of data. But considering the following scenario how should be the structure of the curl application for OCC.

If the applet makes frequent query to another web server using HTTP GET/POST for each of its operation, then how can the curl applet will work in offline mode? No doubt the applet's code is at client’s machine, but it cannot get access to the real server which holds the data. So, I believe, not all applications can be suitable for OCC. Yes, there may be other kind of application where OCC can be a fantastic feature.

To understand it better we can think of outlook which works on offline mode too. We can even read, compose mails without connecting to internet. But once it is connected it synchronizes the data with the server. Is there any curl native API to implement such kind of feature? Or we have to implement complex logic at client side to keep the offline data in a secure place and make the actual request when the application becomes online.

And how can we control which data should be get downloaded along with the code for an OCC application? In other words is there anyway to guide the OCC applet to fetch only specific data from a server and make it available for offline browsing? And how much data can we download for OCC? Or we have to make use of CSPD (Client Side Persistent Data) manually to store the applet data at client's machine.

What about code hiding for a OCC enabled application? My understanding is that, if the source code will make a copy of it at client's machine then we cannot hide the source code of the application. Then how to achieve code hiding?

Is there any more detailed documentation available for OCC apart from IDE documentation? Need your valuable inputs to understand it better.
Click to view Duke's profile Curl Duke 116 posts since
Oct 17, 2007
1. Re: Need more details on OCC Jun 17, 2008 11:07 PM
Other people can address what to do about syncing data and preparing to work in offline mode.

Code hiding is not any different for a local file or OCC applet than it is for an http: applet. In either case, a user can look at the sources; they just have to work a tiny bit harder to see the http: sources. The only code hiding for Curl applets is using the pcurl format, which is a weak form of code hiding.

We don't have documentation about OCC other than what comes with the IDE. We will work on improving the documentation for the Nitro release, along with documenting the new OCC features of the Nitro release.
Click to view wbardwell's profile Curl wbardwell 39 posts since
Oct 31, 2007
2. Re: Need more details on OCC Jun 18, 2008 12:18 PM
URPradhan wrote:Hi Friends

OCC, as the name suggests it gives the flexibility to run curl applets in offline mode. And my understanding from the documentation is that, an OCC enabled application makes a copy of its source code tree on client's machine in user's application directory along with a small amount of data. But considering the following scenario how should be the structure of the curl application for OCC.

If the applet makes frequent query to another web server using HTTP GET/POST for each of its operation, then how can the curl applet will work in offline mode? No doubt the applet's code is at client’s machine, but it cannot get access to the real server which holds the data. So, I believe, not all applications can be suitable for OCC. Yes, there may be other kind of application where OCC can be a fantastic feature.

To understand it better we can think of outlook which works on offline mode too. We can even read, compose mails without connecting to internet. But once it is connected it synchronizes the data with the server. Is there any curl native API to implement such kind of feature? Or we have to implement complex logic at client side to keep the offline data in a secure place and make the actual request when the application becomes online.
The OCC mechanisms include an area on disk at the Url curl://local-data for the OCC applet to write to. This directory is based on the curl-root of the applet, and is private to applets
that share the same curl-root. There is not any provided APIs to help manage that data, and there are many different ways that you might want to manage synchronization, some of the pretty simple, some of them pretty complex. For example the occ-root-installer code uses a very simple one of reading a curl-contents.txt file and checking the timestamp in that against the timestamp already copied to local disk. A similar mechanism is do-able in just a few lines. Synchronizing mail messages from an IMAP or POP server would require much more sophisticated code. Also with the Nitro beta (and eventually in the full release of that) you can use SQLite to make a database file in curl://local-data and manage synchronization with some SQL code. (You can also use SQLite in 6.0 if you have an applet that runs privileged, in either case see the Curl CDK.) Also if you don't need to be sure that the
data from a given Url is available, but you would like to use it if it is, then cacheable content that an applet accessed while connected, will sometimes still be in the HTTP cache and
can be accessed by an offline/disconnected applet. (If the applet wants to be sure that it doesn't cause the machine to dial-up the internet then it can use with-file-caching-style "only-from-cache".)
And how can we control which data should be get downloaded along with the code for an OCC application? In other words is there anyway to guide the OCC applet to fetch only specific data from a server and make it available for offline browsing? And how much data can we download for OCC? Or we have to make use of CSPD (Client Side Persistent Data) manually to store the applet data at client's machine.
An applet can have some static data that is downloaded as part of the OCC install and update, and that is managed as described in the occ-root-installer and occ-module-installer docs.
the CSPD for unprivileged applets has a limit of 256k, but you can store an unlimited amount of data in curl://local-data.
What about code hiding for a OCC enabled application? My understanding is that, if the source code will make a copy of it at client's machine then we cannot hide the source code of the application. Then how to achieve code hiding?
As Duke noted pcurl is the only code hiding available, but there is no difference in code hiding between OCC and regular applets. I suppose that you could do encryption of source code
and then use evaluate to run the decrypted code, but a dedicated user could still see the code in memory once it was decrypted. For any computer language, don't ever count on the code being secret for any real security, because any code can be disassembled or watched from a debugger.
Is there any more detailed documentation available for OCC apart from IDE documentation? Need your valuable inputs to understand it better.
Not yet, although you can also look at some of the Nitro demos posted to developers.curl.com to see how some OCC applets handle some of these issues.
Click to view URPradhan's profile Level 6 URPradhan 108 posts since
Mar 6, 2008
3. Re: Need more details on OCC Jun 20, 2008 2:49 AM
in response to: wbardwell
Thank you for the info.

But still not convinced about OCC, which is a highlighted feature of Curl.

Till now I'm assuming that its feature which copies the source code to client m/c.
I believe; definitely I'm missing some thing about the capabilities of OCC in detail :(
Click to view cbarber's profile Curl cbarber 72 posts since
Sep 27, 2007
4. Re: Need more details on OCC Jun 20, 2008 7:59 AM
in response to: URPradhan
In Curl, all source code is compiled on the client whether in an OCC application or a regular Curl applet. The compressed and obfuscated pcurl format can be used in both cases to make it harder for someone to reverse-engineer your source for all types of Curl deployments but it is not foolproof. Of course, it is impossible to prevent reverse-engineering of any code that you allow to run on a machine not controlled by you, so you should never allow any top-secret code to run on any client-side platform. Fortunately, most companies don't have very much, if any, code that is so sensitive they can't risk any possibility of reverse-engineering on the client machines on which they will be installed.

What OCC gives you is a way to install a Curl application on a machine and run it outside of a browser much as you would a regular compiled desktop application, while retaining Curl's sandbox security model.
Click to view BobM's profile Level 1 BobM 3 posts since
Dec 17, 2007
5. Re: Need more details on OCC Jun 23, 2008 9:38 AM
in response to: URPradhan

Hi URPradhan,


You ask a couple of great questions. I don't know if I can help you but I will try. OCC is about makeing a way for a user to run a Rich Internet Applicaiton when the internet isn't always there. If you need the internet all the time in your application then OCC doesn't work - and that is fine. There are lots of things would make good OCC applications and the capabilities in Curl allow you to create them. I think there are three main features of OCC:

Store a copy of the page (application) locally. \\ A self aware Application - am I connected or not. \\ An ability to store data locally for offline use and the ability to connect to it when on line.

I think an OCC application is more complex then a pure transactional - and thought needs to go into what data is synchronized and what is the right way to do it. With Curl you have the ability to implement what you need to. Email and Calendar are great examples as are countless others. OCC isn't an end all - it is a capability to allow you to do somethign that couldn't otherwise do.


Bob

PS - I worked at Curl when OCC was created - views are my own.

Click to view URPradhan's profile Level 6 URPradhan 108 posts since
Mar 6, 2008
6. Re: Need more details on OCC Jun 25, 2008 2:31 AM
in response to: BobM
Thank you all friends. Now I have a better understanding about OCC.

Lets again come back to the main question, How to manage which data, should be downloaded along with code ?

Is it controlled by "occ-root-installer's" "curl-contents.txt" file ?
Means what ever the file we will specify those will only be downloaded to client's m/c.
If yes, then we will have to store the application DATA as Files at server ?
Or can we put a database at web server and will tell "occ-root-installer" to fetch a particular table or a particular set of records ?

Need more detail info about controlling the DATA that gets downloaded for an OCC application and about "occ-root-installer".

Thank you in adv.
Click to view Duke's profile Curl Duke 116 posts since
Oct 17, 2007
7. Re: Need more details on OCC Jun 25, 2008 3:53 PM
in response to: URPradhan
If you had a whole database to download , and that data would be rarely updated, then you might use the Curl installer procedures to manage the files or data.

But if you are dealing with a database that is too large to download, and which might also be getting updated frequently, then I think you will want some synchronization mechanism other than the Curl installers. I don't know if SQLite has some readily available sync support, but the same problem comes up with other RIA platforms. You might look at http://blog.lab49.com/archives/1569 for a discussion of the same problem for Adobe AIR.
Click to view URPradhan's profile Level 6 URPradhan 108 posts since
Mar 6, 2008
8. Re: Need more details on OCC Jun 26, 2008 5:23 AM
in response to: Duke
Thank you Duke.

Lets keep synchronization aside for a moment and lets talk about only static data.
As the documentation for OCC says.... An OCC application gets downloaded to client m/c along with few application data.
So, I just wonder the meaning of DATA here. Means how it knows which data; where we are specifying the source/size of data ?
I'm not seeing any thing inside "occ-root-installer".

Lets say my OCC application needs 10 rows of read-only static data from a database table from webserver. So where I'll have to mention this in an OCC application. Will it store the data locally if one of my applications source file calls a method to fetch 10 rows from a database like "Select * from sample where row_count < 10" ?

I'm sorry, if I'm going off topic.

Thank you
Click to view BobM's profile Level 1 BobM 3 posts since
Dec 17, 2007
9. Re: Need more details on OCC Jun 26, 2008 4:03 PM
in response to: URPradhan

One note - my experience is from a while ago so things may be different and certainly so if you are using the Nitro Beta.


There are a couple of options availible depending on the security level that the occ applicaition is given. The most likely approach is to just save data on the file system within the OCC data area that can be set up for the OCC application. When you run the installer the user is asked if theOCC applicaition should be allowed to store data on the local file system, if they answered yes then you can read and writedata to files in "curl://local-data". With this you could read the 10 records from the server and then write them to a file in this location.

IF writeing a file isn't good enough then you could tie into a local database. I haven't played with the Nitro beta yet but it looks like it contains a sql db. You could also look at the Sourceforge project https://sourceforge.net/forum/forum.php?forum_id=840192 for a non-nitro solution.

There is also a capability called Client-side Persistent Data that lets you store data without the local data permisions needed for OCC. I recall that serialization of data could be a challange so this was best used for smallish amounts of data that is simple (10 records should be ok).


Bob


Click to view Duke's profile Curl Duke 116 posts since
Oct 17, 2007
10. Re: Need more details on OCC Jun 26, 2008 4:04 PM
in response to: URPradhan
Good question. If you have the static data in a file, then that can be part of a project that the IDE deploys for OCC, which will take care of some of the details about the curl-archive.car and curl-timestamp.txt files.

If the data was not initially available to be deployed as a file in the IDE's project, then you will have to take care yourself of storing it in a local file. OCC applets are able to read and write files in a "sandbox" area of the local disk which is referred to by the URL curl://local-data/. That sandbox of local storage is only accessible to the applet and other applets from the same web server directory, unless you take steps to make it shared by a larger group of applets. So after the OCC applet has been installed, the code you wrote in the applet would read data from the network, and then you would also have written code to store the data in a format of your choice to some file like curl://local-data/my-rows.db

For some types and amounts of data, the Curl persistent-data API could be an alternative to writing to files in curl://local-data/ , but that would also be the same kind of code you would have to write yourself.

The other thing that affects these choices is if the applet is going to be modifying this data, and then the developer has to make some decisions about how to manage the changed data - whether it needs to be sent back to the server, and how to avoid losing your changes if you are going to be getting some updated data from the server. Right now, Curl does not have built-in support for organizing the synchronization.
Click to view BobM's profile Level 1 BobM 3 posts since
Dec 17, 2007
11. Re: Need more details on OCC Jun 27, 2008 1:50 PM
in response to: URPradhan
I have a simple OCC app that demonstrates what i was talking about. It is at

http://www.westboro.org/occ1/start.curl


The code is commented and a zip file of the project and the server php file that retrieves the 10 records from the DB is included.


http://www.westboro.org/occ1/occ1.zip


A quick description is:


Lines 1-11 - Herald and OCC installer


Lines 23-43 - If connected then get the records from the server DB and store a local copy.


Lines 46-59 - If not connected read from the file


Line 61 - Display what we did.


Bob