DecsyncCC doesn’t expect anything, yet – they had mentioned in the related issue that there wasn’t any way to know if Syncthing had done an update.
Probably the simplest to implement by both parties would be:
- Syncthing sends a broadcast intent when it finishes a folder (reaches 100% after not being at 100%)
- Syncthing provides some documentation specifying that it is doing this, like “Integrating with Syncthing”
- Decsync listens to
Syncthing’s side would look something like this:
final Intent i = new Intent();
i.setAction("com.github.catfriend1.syncthingandroid.ACTION_NOTIFY_FOLDER_UPDATE_COMPLETE");
i.putExtra("com.github.catfriend1.syncthingandroid.FOLDER_ROOT_PATH", "/path/to/share_folder_root");
i.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); # not sure if this line is needed
getApplicationContext().sendBroadcast(i);
setAction
should have your app prefixed, as shown (if that’s your app prefix). The action name itself is CAPS_VALID_IDENTIFIER, but the action name is arbitrary otherwise.
putExtra
doesn’t need to be prefixed by your app name – it can be whatever key you’d like it to be, and you can put more than one. It could simply be “root_path” instead of “com.github.catfriend1.syncthingandroid.FOLDER_ROOT_PATH”
You can add as many of these intents as you’d like, I don’t think spamming is an issue, it’s a pub/sub model. But, the above would suffice.
Mainly, DecsyncCC needs to know:
- that an update has occurred, and is finished
- where it occurred (root folder path)
To get that info, the developer of DecsyncCC or anyone else seeking to integrate needs to know the following information, theoretically provided in your documentation:
- The action key you will be using, prefixed by your app id as in the example
- The key the relevant data will be stored in
- The datatype or format of the relevant data (a string, and whether or not that’s JSON, or a double, or a bundle, or… or… or…)
That being the case, I figure in your documentation somewhere, you could have an “Integrating with Syncthing” section that specifies that data for each of the events you’ll be sending.
So, can you send last changed file and completion percent? Sure, particularly if you include the share root. But, my guess is that DecsyncCC will probably just wait for “100%”, then do its own scan. But, they might utilize the individual files if sent. Hard to say. Someone out there might want to hook into Syncthing, and who knows what they’ll want? It’s more about how much dev time you want to do on it.
…an example matching your idea there:
final Intent i = new Intent();
i.setAction("com.github.catfriend1.syncthingandroid.ACTION_NOTIFY_FOLDER_UPDATE_PROGRESS");
i.putExtra("folder_root", "/path/to/share_folder_root");
i.putExtra("percent_complete", "87%"); # or whatever type you want to send that data as
i.putExtra("last_file_changed", "/path/to/share_folder_root/snoo.txt");
i.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); # not sure if this line is needed
getApplicationContext().sendBroadcast(i);
Hope that’s helpful, sorry if it’s just wall-of-text.