2015-03-02 63 views
1

我正在开发使用libedataserver.so的Thunderbird插件。GDK ESourceRegistry用于工作但不再是

Addon使用js-ctypes从上述库中调用e_source_registry_new_sync。请参见下面的代码:

var lib = ctypes.open("libedataserver-1.2.so.18"); 

    var GCancellable = {}; 
    GCancellable.cls = new ctypes.StructType("GCancellable"); 
    var GError = {}; 
    GError.cls = new ctypes.StructType("GError"); 

    var ESourceRegistry = {}; 
    ESourceRegistry.cls = new ctypes.StructType("ESourceRegistry"); 
    ESourceRegistry.e_source_registry_new_sync = 
     lib.declare(
      "e_source_registry_new_sync", 
      ctypes.default_abi, 
      ESourceRegistry.cls.ptr, 
      GCancellable.cls.ptr, 
      GError.cls.ptr.ptr); 

    //below line causes an error 
    var sourceRegistry = ESourceRegistry.e_source_registry_new_sync(null, null); 

它完美罚款在Ubuntu然而在Fedora 21将打印输出以下,然后挂断:

(thunderbird:2735): GLib-GObject-WARNING **: cannot register existing type 'EDBusSource' 
(thunderbird:2735): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion 'G_TYPE_IS_INTERFACE (interface_type)' failed 
(thunderbird:2735): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed 
(thunderbird:2735): GLib-GObject-WARNING **: invalid cast from 'EDBusSourceProxy' to '<invalid>' 

我使用的Fedora 21演进数据服务器11年3月12日-1.fc21。

Ubuntu使用evolution-data-server 3.12.10。

我开发了简单的C应用程序,它调用e_source_registry_new_sync,它工作得很好。

有人可以提出什么可能是这个问题的原因?我提出了Fedora bug。根据Fedora的维护者问题是由加载libedataserver两次引起的(我的代码和演进EWS):

这个问题似乎是在它自己的那雷鸟负载libedataserver-1.2.so.18,而libcamelews.so对libedataserver-1.2.so具有运行时依赖性,但这不是(在运行时)由thunderbird加载的libedataserver-1.2.so.18满足的,因此它再次被加载,这打破了GLib类型系统。

请评论,如果有什么我可以从插件方面做的。

+1

嘿@Mateusz这是一个很好的问题。它没有得到太多的关注,因为这些标签并不受jsctypes人们的欢迎。坚持在Firefox的插件标签,你会得到一个更快的repsonse :)你可以发布你的代码,所以我可以测试Ubuntu和Fedora – Noitidart 2015-03-11 05:30:44

+0

感谢您分享您的评论从Fedora团队。我想我们可以解决这个问题。你知道一种方法来检查哪些库被加载到雷鸟吗?如果没有,我们可以找出,而且我们会运行一个工具来查找所有libedataserver-1.2.so的路径,并尝试从所有这些路径中尝试。这可能是因为雷鸟已经加载了这个库,但有不同的路径,所以它得到双重加载,请尝试进入#jsctypes频道,我们可以敲掉这个 – Noitidart 2015-05-06 07:35:23

回答

0

你问有关错误使用此功能在发生:https://developer.gnome.org/libedataserver/stable/ESourceRegistry.html#e-source-registry-new-sync

该文档指出出错,NULL返回和GError设置为合适。稍后我会测试代码,看看发生了什么,但我会告诉你如何自己测试它。

GError不是一个opque结构。其定义是这样的:

var GQuark = ctypes.uint32_t; 
GError.cls = new ctypes.StructType('GError', [ 
    {'domain': GQuark}, 
    {'code': ctypes.int}, 
    {'message': ctypes.char.ptr} 
]); 

从这里摘自:https://gist.github.com/Noitidart/dbe54fcd7794c8ddff6f#file-_ff-addon-snippet-gdk_giolaunch-js-L22

然后设置你的代码返回错误是这样的:

var error = GError.cls.ptr(); // can use `null` if we dont care to see error but we want to know what is happening so we can fix it 
var sourceRegistry = ESourceRegistry.e_source_registry_new_sync(null, error.address()); 
if (sourceRegistry.isNull()) { 
    console.error('An error occured when calling e_source_registry_new_sync!'); 
    console.info('ERROR DETAILS', 'Domain:', error.contents.domain.toString(), 'Code:', error.contents.code, 'Message:', error.contents.message.readString()); 
} 

然后基于错误的详细信息查找代码和消息,它会告诉你发生了什么,然后在不明显的情况下搜索StackOverflow或其他解决方案。

+1

感谢您的评论。问题是'sourceRegistry.isNull()'永远不会到达。 Code Stucks on: 'ESourceRegistry.e_source_registry_new_sync(null,error.address());' – 2015-05-06 06:15:34

+0

@MateuszBalbus我非常非常奇怪,我复制粘贴代码,它在Ubuntu上运行得很好。你可以使用moz IRC频道的#jsctypes,你可以使用这个在线聊天客户端:https://client00.chat.mibbit.com/?url=irc%3A%2F%2Firc.mozilla.org%2F%23jsctypes我们可以帮忙你修复了这个问题 – Noitidart 2015-05-06 07:32:06

+0

正如后文所述:“在Fedora 21上,它在Ubuntu上运行得非常好” 您需要安装带有evolution-ews的Fedora 21(应该默认安装)。卸载evolution-ews可以解决问题。 – 2015-05-06 07:51:01