如何集成 Firefox 同步?
Firefox 4 即将推出(好吧,明年;))并且有一个 Firefox 插件可以将您的书签等与 Firefox 3 同步。
我想知道是否有人有一个全面的、最新的教程来将 Firefox Sync 集成到您自己的插件中?或者对此有什么想法吗?
我主要遵循这个官方“教程”以及这篇博文,但信息似乎有点过时。
例如,该对象不再称为 Weave
,而是 Engines
,并且 weave.engines.
首选项变为 services.sync.engines。
。我对所有提到的选项进行了一些尝试,但它似乎不起作用(并且我的插件没有显示在您可以选择同步内容的列表中)。
我认为 Tracker 和 Store 类都很好,主要问题是注册引擎...
Firefox 4 comes soon (ok, next year ;)) and there is a Firefox plugin to sync your bookmarks etc. with Firefox 3.whatever .
I would like to know if anyone has a comprehensive, up-to-date tutorial to integrate Firefox Sync into your own plugin? Or any idea regarding this?
I mainly followed this official "tutorial" and also this blog post, but the information seems to be slightly outdated.
For example, the object is not called Weave
anymore but Engines
and the weave.engines.
preference became services.sync.engines.
. I played a little with all the mentioned options, but it does not seems to work (and my plugin does not show up in list where you can select what to sync).
I assume that the Tracker
and Store
classes are fine, the main problem is to register the engine...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您提到的 ClientAPI 教程绝对是正确的选择。我最近更新了它,所以如果有问题,请告诉我们,以便我可以在文档中修复它。弗拉基米尔 (Wladimir) 的博文确实相当古老,并且包含一些过时的信息。我们还将在即将发布的测试版中对 API 的某些部分进行更改,因此请做好应对变化的准备...
Weave
命名空间仍然是从 UI 代码访问 Sync 相关 API 的规范方式。它公开了诸如Weave.Service
和Weave.Engines
之类的组件。您可以通过Components.utils.import("resource://services-sync/main.js")
导入它。如果您想实现自己的引擎,则必须导入实际的底层模块(所有这些都在 ClientAPI 教程中列出)。本教程还介绍了如何注册自定义引擎实现。不过,一旦注册,它就不会自动显示在首选项用户界面中。我建议构建您自己的 UI,以翻转附加组件首选项中的services.sync.engine.YOURENGINE
首选项。出于好奇,您想要同步什么样的数据?
The ClientAPI tutorial you mention is definitely the way to go. I updated it recently so if something's not working, please let us know so I can fix it in the docs. Wladimir's blogpost is definitely quite old and contains some outdated information. We will also make changes to some parts of the API in the upcoming beta releases, so be prepared for some flux...
The
Weave
namespace is still the canonical way to access Sync related APIs from UI code. It exposes components such asWeave.Service
andWeave.Engines
. You can import it viaComponents.utils.import("resource://services-sync/main.js")
. If you want to implement your own engine, you'll have to import the actual underlying modules, though (all listed in the ClientAPI tutorial). The tutorial also describes how to register your custom engine implementation. Once it's registered, it won't automatically show up in the preferences UI, though. I suggest building your own UI that flips theservices.sync.engine.YOURENGINE
pref in your add-on's preferences.Out of curiosity, what kind of data are you trying to sync?