Data syncing with DropBox API and iOS - iphone

I have an iOS app which stores data in the local directory. I'd like to be able to sync this data between multiple devices running my app. Currently this is using core data, but I'd expect to have to change to some text-based file storage system to make syncing easier.
I was expecting the DropBox API would make this nice and easy, and that I could tell the API to simply sync the contents of my data folder on startup/save. However it seems the DropBox API is nothing more than a glorified way of uploading and downloading files.
Am I wrong on this assumption? Can the DropBox API actually make it easy to keep a folder full of text files in sync? If not, is there some other service or even advice you can give? Syncing is hard - I was hoping DropBox would make it easier.

Using /metadata, getting information about the contents of a folder couldn't be easier. All you need to do is check the modified date, and if it's different than yours locally, perform the appropriate action. It will also give you the metadata for any file contents, so you can pick out which files need to be uploaded / downloaded / added / removed as necessary.
Any more functionality than this would be very application-dependent; you can decide for yourself when and how you want to deal with differing files.
Dropbox API Documentation

Won't repeat since Andy has answered your question, thought you may also find this tutorial helpful:
http://www.nanaimostudio.com/blog/2011/1/20/how-to-synchronize-your-app-data-using-dropbox-api.html

Check out the new DropBox Sync API.

As ohho mentioned, there's the DropBox Sync API available now which I think will do what you mentioned (I haven't tried it personally, as I integrated support for Dropbox in my app using the earlier SDK, before this came along). This will probably suffice if you're just working with dropbox.
In my case I've been starting to add support for additional online storage ("Cloud") services to my app, and am finding that it's somewhat challenging to deal with the differences between them in how they handle various concepts like authentication, version, naming etc. For example Dropbox's API references files according to their path, whereas Box's API references files according to their file id (which has an associated path, but I believe remains the same if the file is moved). Then there's also all the issues of conflict resolution (aka merging) which come about when multiple clients try and sync conflicting changes to the server.
I've actually been recently considering starting an open source project to develop a library which can connect to all the major services, and provide an abstraction layer that papers over their differences, and also handles the syncing process for you. I've actually got some code already (which I haven't publicly released to date) but could use that to get the project started.
Would this be of use to you? Would you (or any others) be willing to participate in such an effort?
(note to mods: I realise this may be deviating somewhat off-topic - sorry about that. If you can recommend a more suitable forum to discuss this I'd be happy to take the conversation there).

There is a RSS feed that can be limited to one of the shared folders but it kind of filters events to keep volumes low.

Related

SMB/samba support on iOS?

I check iOS document and also google it for a while and get the impression that iOS does not support samba (although there is a samba app for jailbreak iPhone).
But then how do the app FileBrowser achieves that? Does that mean they implemented samba support by their own ?
I also find there is an open source library called tango that provides limited support for samba. So my question is that the best samba support I can get ?
I spent quite some time in implementing my own SMB client so I would like to share some experience here.
First do not use tango in your production code because once you become familiar with SMB you will realize that its implementation is problematic, e.g. it does not support unicode and in some several cases it is not correctly padding so you can't access the folder. And I also heard people said they can't connect window 7 with it.
Second, to summarize my experience I find jcifs guys had said the best: "anyone who wants to implement the CIFS needs to know one very important thing - the "official" CIFS documentation is not accurate
and does not reflect reality. There is NO specification. Do not believe anything you read in the IETF draft or the SNIA document (same document different formatting). Use it only as a hint. The definitive reference is whatever you see on the wire.
WireShark Rules!
... look at JCIFS for design inspiration such as how it puts the request and response into a map by MID and encodes and decodes frames.
Then implement the following commands:
SMB_COM_NEGOTIATE
SMB_COM_SESSION_SETUP_ANDX
SMB_COM_TREE_CONNECT_ANDX
SMB_COM_NT_CREATE_ANDX
SMB_COM_READ_ANDX
SMB_COM_WRITE_ANDX
SMB_COM_CLOSE
all responses for above
"
The only thing I can add is that , you also need to implement TRANS2_FIND_FIRST2 request/response to query the files inside a folder and if you want to find out how many shared folders the server exposes you need to implement NetShareEnum Request/Response.
I used libsmbclient from samba package (http://www.samba.org) for SMB operations on iOS.
You can look on my project https://github.com/kolyvan/kxsmb (objective-c wrapper on libsmbclient). For now it supports a limited set of SMB operations. It mostly was designed for browsing local net and retrieving files from SMB shares.
iOS doesn't give you access to a filesystem that you may be used to. You can read and write files inside your own App's private area, but that's all. You could potentially implement another file system in your application, but you won't be able to use normal file operations.
I'd bet FileBrowser implements the protocol inside their app and implements a file system like layer on top of that for access. I'd guess you could either try to port an existing samba library or roll your own.
iOS does not have any APIs to work with SMB. However, SMB is currently documented by Microsoft and implementing it is not impossible (although not easy too). I've created a freeware project which contains most of what you need to handle SMB. See
https://sourceforge.net/projects/smb4ios/

Git client on the iPhone, possible? How?

Is it possible to embed git in the iPhone app? Only in a passive mode, i.e. to be able to read commit messages (with date and user) and diffs given some online git repository in order to present it in some readable table views?
I'm one of the co-authors of cocoagit, which is currently an unfinished implementation of the core git functionality in Objective-C. There has not been much activity in the last 6 months. Unfortunately, it is not far quite far enough along to do everything you need. We can read commits, and have preliminary support for cloning repos, but we can't do diffs yet. Geoff and I would both like to have more time to work on it again, but in the meantime, we would gladly welcome any contributions.
Alternatively, I second the recommendations of previous posters to consider using github, or building your own web service to provide the necessary data.
Git (the command-line client) has been ported to jailbroken iPhones.
It would be easier to write a webapp that generated iPhone specific formatted output. Anything is possible on the iPhone, but to get an App on it you have to pay the $99 to join the club and then run the gauntlet of the Approval Process. A web app doesn't have to be approved by anyone.
It would be possible if you could statically compile the required git functions into your executable. It would require cloning the repository to the device’s disk though.
I’m not sure what your use-case is, but using a hosted website such as GitHub, or making your own web service if that is not possible, would likely be more sensible.
Not sure if this github client for iphone would offer any pointers
http://github.com/schacon/igithub/
It is definitely possible. The BugBranch app does this. According to the about section of the app, it uses libgit2 and objective-git.
You've got a couple options:
1) Get git(1) cross compiling for ARM and the iPhone and then embed them.
2) Use Dulwich and write a small tool you can drive with NSTask that does what you need (don't link your code directly to this or copy their implementation -- it's GPL). This is likely easier than option 1.
3) Write a web server which does what you need and then have your iPhone client access this.
It really depends on what you're doing, why you're doing it, and what infrastructure you've already got set up which option will be the best. For instance, if you already have any sort of server component already (e.g. for push notifications) I would recommend option 3.

need to implement versioning in Online backup tool

I am working on the developement of a application that will perform online backup of the files and folder in the PC, automatically or manually. Currently, I was keeping only the latest version of the file at the server.Now, I have to implement the versioning so that only the changes can be transfered to the online server and user must be able to download any of the available version of the file at Backup Server.
I need to perform Deduplication for this. Guys, though I am able to perform it using the fixed block size but facing an overhead of transferring the file having CRC information with each version backup.
I have never worked on such technology , so lacks in experience. I am eager to know is there any feasible method to embedd this functionality in the application without much pain. Is any third party tool would help to perform same thing? Please let me know?
Note: I am using FTP protocol to transfer the data.
There's a program called dump that does something similar, but it operates on filesystem blocks rather than files. rsync also may be of interest.
You will need to keep track of a large number of blocks with multiple versions and how they fit into the various versions of the original files, so you will need some kind of database to track this information, and an efficient way to query it to determine which blocks in a given file need to be transferred. Also note that adding something to the beginning of a file will cause all your blocks to be "new" if you use a naive blocking and diff scheme.
To do this well will be very complex. I highly recommend you thoroughly research already-available solutions, and if you decide you need to write your own, consider the benefits of their designs carefully.

Is there any form of Version Control for LSL?

Is there any form of version control for Linden Scripting Language?
I can't see it being worth putting all the effort into programming something in Second Life if when a database goes down over there I lose all of my hard work.
Unfortunately there is no source control in-world. I would agree with giggy. I am currently moving my projects over to a Subversion (SVN) system to get them under control. Really should have done this a while ago.
There are many free & paid SVN services available on the net.
Just two free examples:
http://www.sourceforge.net
http://code.google.com
You also have the option to set one up locally so you have more control over it.
Do a search on here for 'subversion' or 'svn' to learn more about how to set one up.
[edit 5/18/09]
You added in a comment you want to backup entire objects. There are various programs to do that. One I came across in a quick Google search was: Second Inventory
I cannot recommend this or any other program as I have not used them. But that should give you a start.
[/edit]
-cb
You can use Meerkat viewer to backupt complete objects. or use some of the test programas of libopenmetaverse to backup in a text environment. I think you can backup scripts from the inventory with them.
Jon Brouchoud, an architect working in SL, developed an in-world collaborative versioning system called Wikitree. It's a visual SVN without the delta-differencing that occurs in typical source code control systems. He announced that it was being open sourced in http://archvirtual.com/2009/10/28/wiki-tree-goes-open-source/#.VQRqDeEyhzM
Check out the video in the blog post to see how it's used.
Can you save it to a file? If so then you can use just about anything, SVN, Git, VSS...
There is no good source control in game. I keep meticulous version information on the names of my scripts and I have a pile of old versions of things in folders.
I keep my source out of game for the most part and use SVN. LSLEditor is a decent app for working with the scripts and if you create a solution with objects, it can emulate alot of the in game environment. (Giving Objects, reading notecards etc.) link text
I personally keep any code snippets that I feel are worth keeping around on github.com (http://github.com/cylence/slscripts).
Git is a very good source code manager for LSL since its commits work line-by-line, unlike other SCM's such as Subversion or CVS. The reason this is so crucial is due to the fact that most Second Life scripts live in ONE FILE (since they can't call each other... grrr). So having the comparison done on the file level is not nearly as effective. Comparing line by line is perfect for LSL. With that said, it also (alike SourceForge and Google Code) allows you to make your code publicly viewable (if you so choose) and available for download in a compressed file for easier distribution.
Late reply, I know, but some things have changed in SecondLife, and some things, well, have not. Since the Third Party Viewer policy still keeps a hard wall up against saving and loading objects between viewer and system, I was thinking about another possibility so far completely overlooked: Bots!
Scripted agents, AKA Bots, have all usual avatar actions available to them. Although I have never seen one used as an object repository, there is no reason you couldn't create one. Logged in as a separate account the agent can be wherever you want automatically or by command, then collect any or all objects you are working on at set intervals or by command, and anything they have collected may be given to you or collaborators.
I won't say it's easy to script an agent, and couldn't even speak for making an extension to a scripted agent myself, but if you don't want to start from scratch there is an extensive open source framework to build on, Corrade. Other bot services don't seem to list 'object repository' among their abilities either but any that support CasperVend must already provide the ability to receive items on request.
Of course the lo-fi route, just regularly taking a copy and sending the objects to a backup avatar, may still be a simple backup solution for one user. Although that does necessitate logging in as the other account either in parallel or once every 20 or-so items to be sure they are being received and not capped by the server. This process cannot rename the items or sort them automatically like a bot may. Identically named items are listed in inventory as most recent at the top but this is a mess when working with multiples of various items.
Finally, there is a Coalesce feature for managing several items as one in inventory. This is currently not supported for sending or receiving objects, but in the absence of a bot, can make it easier to keep track of projects you don't wish to actually link as one item. (Caveat; don't rezz 'no-copy' coalesced items near 'no-build' land parcels, any that cannot be rezzed are completely lost)

How do I sync my development with the users?

I create websites for people. I have given them the ability to edit certain areas of their published pages using CushyCMS. That works fine, and everyone is happy with it.
When I go to publish some of my more extensive changes, I first need to pull down the latest version that they have produced. Then I make my changes, and upload everything to production.
I would like to use some sort of version control in this process. This should be a classic update-edit-commit-publish workflow, but I'm not sure how to go about this. Basically I want to avoid pulling down everything locally and doing the commits. I only want to pull down what has changed.
I use filezilla, and it doesn't do a good job of identifying changed files. I can't rely on the filesize, because sometimes it stays the same. I can't rely on timestamps because the server time is different than my machine, and it never seems to work correctly.
How can I get around my problem? I use Notepad++, Subversion and FileZilla, but I'm willing to try other tools if they would make this process easier.
It comes down to CushyCMS's decision to edit files directly and not put the user-provided content in a database like WordPress, DotNetDuke, Drupal, etc. So the real answer is you can't get there from here and should look into migrating to a database backed CMS. Thats not what you want to hear though.
Version control will get you part of the way to concurrency but there is always the possibility of a user updating a page between your pull down and publishing the revised copy since your users wouldn't be checking into the version control system directly. That would require them to learn the version control system and negate the ease that CushyCMS (or any CMS really) provides. You'll want to try and find a system that allows your live site to be the Master to which you compare and check-out files from. I do not know of any mainstream systems that currently work that way.
I found that it was easiest to use a tool like Beyond Compare to handle the synchronization.