{"id":289507,"date":"2024-01-17T21:24:21","date_gmt":"2024-01-17T13:24:21","guid":{"rendered":"https:\/\/lrxjmw.cn\/lcydjcjtxfs.html"},"modified":"2024-01-17T21:24:21","modified_gmt":"2024-01-17T13:24:21","slug":"lcydjcjtxfs","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lcydjcjtxfs.html","title":{"rendered":"2Linux\u5e38\u7528\u7684\u8fdb\u7a0b\u95f4\u901a\u4fe1\u65b9\u5f0f"},"content":{"rendered":"

1\u76ee\u7684<\/p>\n

\u5bf9\u6bd4\u8fdb\u7a0b\u95f4\u901a\u8baf\u65b9\u6cd5\uff0c\u9009\u62e9\u9002\u5b9c\u5e73\u53f0\u5f00\u53d1\u7684\u8fdb\u7a0b\u95f4\u901a\u8baf\u65b9\u5f0f\u3002<\/p>\n

\u82e5\u679c\u662f\u5f00\u6e90\u6a21\u5757\u7684\u8bdd\uff0c\u91cd\u70b9\u8003\u5bdf\u901a\u8baf\u673a\u5236\uff0c\u63d2\u53e3\u5c01\u88c5\u7a0b\u5ea6\uff0c\u7a33\u5b9a\u6027\uff0c\u4f7f\u7528\u662f\u5426\u7b80\u6613\u3002<\/p>\n

2Linux<\/a>\u5e38\u7528\u7684\u8fdb\u7a0b\u901a\u8baf\u65b9\u6cd5\u7b80\u4ecb2.1\u7ba1\u7ebf<\/p>\n

\u7ba1\u7ebf\uff08Pipe\uff09\u53ca\u6709\u540d\u7ba1\u7ebf\uff08namedpipe\uff09\uff1a\u7ba1\u7ebf\u53ef\u7528\u4e8e\u5177\u6709\u4eb2\u7f18\u5173\u7cfb\u8fdb\u7a0b\u95f4\u7684\u901a\u8baf\uff0c\u6709\u540d\u7ba1\u7ebf\u514b\u670d\u4e86\u7ba1\u7ebf\u6ca1\u6709\u540d\u5b50\u7684\u9650\u5236\uff0c\u56e0\u800c\uff0c\u9664\u5177\u6709\u7ba1\u7ebf\u6240\u5177\u6709\u7684\u529f\u80fd\u5916\uff0c\u5b83\u8fd8\u5bb9\u8bb8\u65e0\u4eb2\u7f18\u5173\u7cfb\u8fdb\u7a0b\u95f4\u7684\u901a\u8baf\uff1b<\/p>\n

2.2\u8baf\u53f7<\/p>\n

\u8baf\u53f7\uff08Signal\uff09\uff1a\u8baf\u53f7\u662f\u6bd4\u8f83\u590d\u6742\u7684\u901a\u8baf\u65b9\u6cd5\uff0c\u7528\u4e8e\u901a\u77e5\u63a5\u53d7\u8fdb\u7a0b\u6709\u67d0\u79cd\u98ce\u6ce2\u53d1\u751f\uff0c\u4e0d\u4ec5\u7528\u4e8e\u8fdb\u7a0b\u95f4\u901a\u8baf\u5916\uff0c\u8fdb\u7a0b\u8fd8\u53ef\u4ee5\u53d1\u9001\u8baf\u53f7\u7ed9\u8fdb\u7a0b\u672c\u8eab\uff1blinux\u4e0d\u4ec5\u652f\u6301Unix\u521d\u671f\u8baf\u53f7\u8bed\u4e49\u51fd\u6570sigal\u5916linux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u4fe1<\/strong>\uff0c\u8fd8\u652f\u6301\u8bed\u4e49\u7b26\u5408Posix.1\u6807\u51c6\u7684\u8baf\u53f7\u51fd\u6570sigaction\uff08\u5b9e\u9645\u4e0a\uff0c\u8be5\u51fd\u6570\u662f\u57fa\u4e8eBSD\u7684\uff0cBSD\u4e3a\u4e86\u5b9e\u73b0\u53ef\u9760\u8baf\u53f7\u673a\u5236\uff0c\u53c8\u80fd\u5426\u7edf\u4e00\u5bf9\u5916\u63d2\u53e3\uff0c\u7528sigaction\u51fd\u6570\u91cd\u65b0\u5b9e\u73b0\u4e86signal\u51fd\u6570\uff09\uff1b<\/p>\n

2.3\u62a5\u6587<\/p>\n

\u62a5\u6587\uff08Message\uff09\u961f\u5217\uff08\u6d88\u606f\u961f\u5217\uff09\uff1a\u6d88\u606f\u961f\u5217\u662f\u6d88\u606f\u7684\u94fe\u63a5\u8868\uff0c\u5305\u62ecPosix\u6d88\u606f\u961f\u5217systemV\u6d88\u606f\u961f\u5217\u3002\u6709\u8db3\u591f\u6743\u9650\u7684\u8fdb\u7a0b\u53ef\u4ee5\u5411\u961f\u5217\u4e2d\u6dfb\u52a0\u6d88\u606f\uff0c\u88ab\u8d4b\u4e8e\u8bfb\u6743\u9650\u7684\u8fdb\u7a0b\u5219\u53ef\u4ee5\u8bfb\u8d70\u961f\u5217\u4e2d\u7684\u6d88\u606f\u3002\u6d88\u606f\u961f\u5217\u514b\u670d\u4e86\u8baf\u53f7\u627f\u8f7d\u4fe1\u606f\u91cf\u5c11\uff0c\u7ba1\u7ebf\u53ea\u80fd\u627f\u8f7d\u65e0\u683c\u5f0f\u5b57\u8282\u6d41\u4ee5\u53ca\u7f13\u51b2\u533a\u5927\u5c0f\u53d7\u9650\u7b49\u7f3a\u70b9\u3002<\/p>\n

2.4\u5171\u4eab\u663e\u5b58<\/p>\n

\u5171\u4eab\u663e\u5b58\uff1a\u81f4\u4f7f\u591a\u4e2a\u8fdb\u7a0b\u53ef\u4ee5\u8bbf\u95ee\u540c\u4e00\u5757\u663e\u5b58\u7a7a\u95f4\uff0c\u662f\u6700\u5feb\u7684\u53ef\u7528IPC\u65b9\u5f0f\u3002\u662f\u9488\u5bf9\u5176\u4ed6\u901a\u8baf\u673a\u5236\u8fd0\u884c\u6548\u7387\u8f83\u4f4e\u800c\u8bbe\u8ba1\u7684\u3002\u5e38\u5e38\u4e0e\u5176\u5b83\u901a\u8baf\u673a\u5236\uff0c\u5982\u8baf\u53f7\u91cf\u7ed3\u5408\u4f7f\u7528\uff0c\u6765\u8fbe\u5230\u8fdb\u7a0b\u95f4\u7684\u540c\u6b65\u53ca\u4e92\u65a5\u3002<\/p>\n

2.5\u8baf\u53f7\u91cf<\/p>\n

\u8baf\u53f7\u91cf\uff08semaphore\uff09\uff1a\u4e3b\u8981\u4f5c\u4e3a\u8fdb\u7a0b\u95f4\u4ee5\u53ca\u540c\u4e00\u8fdb\u7a0b\u4e0d\u540c\u7ebf\u7a0b\u4e4b\u95f4\u7684\u540c\u6b65\u624b\u6bb5\u3002<\/p>\n

2.6Socket<\/p>\n

\u5957\u63d2\u53e3\uff08Socket\uff09\uff1a\u66f4\u4e3a\u901a\u5e38\u7684\u8fdb\u7a0b\u95f4\u901a\u8baf\u673a\u5236\uff0c\u53ef\u7528\u4e8e\u4e0d\u540c\u673a\u5668\u4e4b\u95f4\u7684\u8fdb\u7a0b\u95f4\u901a\u8baf\u3002\u539f\u672c\u662f\u7531Unix\u7cfb\u7edf<\/a>\u7684BSD\u5206\u652f\u5f00\u53d1\u4e0b\u6765\u7684\uff0c\u4f46\u73b0\u4eca\u901a\u5e38\u53ef\u4ee5\u79fb\u690d\u5230\u5176\u5b83\u7c7bUnix\u7cfb\u7edf\u4e0a\uff1aLinux\u548cSystemV\u7684\u53d8\u79cd\u90fd\u652f\u6301\u5957\u63a5\u5b57\u3002<\/p>\n

2.7\u5c0f\u7ed3<\/p>\n

\u6b64\u5904\u53ea\u662f\u7b80\u5355\u4ecb\u7ecd\u4e86Linux\u5185\u6838\u63d0\u4f9b\u7684\u8fdb\u7a0b\u95f4\u901a\u8baf\u7684\u65b9\u6cd5\uff0c\u5177\u4f53\u4f7f\u7528\u65b9\u5f0f\u53ef\u4ee5\u53c2\u7167\u300alinux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u8baf(\u5168)\u300b<\/p>\n

\u9644\u4ef6\uff1a<\/p>\n

3D-bus\u7b80\u4ecb3.1\u4e3b\u8981\u4f5c\u7528<\/p>\n

1.\u5728\u540c\u4e00\u4e2a\u684c\u9762\u4f1a\u8bdd\u4e2d\uff0c\u8fdb\u884c\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u4e4b\u95f4\u7684\u901a\u4fe1<\/p>\n

2.\u684c\u9762\u7a0b\u5e8f\u4e0e\u5185\u6838\u6216\u5219\u5b88\u62a4\u8fdb\u7a0b\u7684\u901a\u8baf\u3002<\/p>\n

3.2\u8fdb\u7a0b\u901a\u8baf\u4f53\u7cfb<\/p>\n

\u5b83\u6709\u4ee5\u4e0b\u51e0\u5c42\uff1a<\/p>\n

1.libdbus\u5e93\uff0c\u63d0\u4f9b\u7ed9\u5404\u4e2a\u5e94\u7528\u7a0b\u5e8f\u8c03\u7528\uff0c\u4f7f\u5e94\u7528\u7a0b\u5e8f\u5177\u6709\u901a\u8baf\u548c\u6570\u636e\u4ea4\u6362\u7684\u80fd\u529b\uff0c\u4e24\u4e2a\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u76f4\u63a5\u8fdb\u884c\u901a\u8baf\uff0c\u5982\u540c\u662f\u4e00\u6761socket\u901a\u9053\uff0c\u4e24\u4e2a\u7a0b\u5e8f\u4e4b\u95f4\u6784\u5efa\u901a\u9053\u4ee5\u540e\uff0c\u5c31\u53ef\u4ee5\u901a\u4fe1\u4e86\u3002<\/p>\n

2.\u6d88\u606f\u5b88\u62a4\u8fdb\u7a0b\uff0c\u5728libdbus\u7684\u57fa\u7840\u4e0a\u521b\u5efa\uff0c\u53ef\u4ee5\u7ba1\u7406\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e4b\u95f4\u7684\u901a\u8baf\u3002\u6bcf\u4f4d\u5e94\u7528\u7a0b\u5e8f\u90fd\u548c\u6d88\u606f\u5b88\u62a4\u8fdb\u7a0b\u6784\u5efadbus\u7684\u94fe\u63a5\uff0c\u4e4b\u540e\u7531\u6d88\u606f\u5b88\u62a4\u8fdb\u7a0b\u8fdb\u884c\u6d88\u606f\u7684\u5206\u6d3e\u3002<\/p>\n

3.\u5404\u7c7b\u5305\u88c5\u5e93linux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u4fe1<\/strong>\uff0c\u6709libdbus-glib\uff0clibdbus-qt\u7b49\u7b49\uff0c\u76ee\u7684\u662f\u5c06dbus\u7684\u5e95\u5c42api\u8fdb\u884c\u4e00\u4e0b\u5c01\u88c5\u3002<\/p>\n

\u5728DBus\u7684\u4f53\u7cfb\u4e2d\uff0c\u6709\u4e00\u4e2a\u5e38\u9a7b\u7684\u8fdb\u7a0bDaemon\uff0c\u6240\u6709\u8fdb\u7a0b\u95f4\u7684\u4ea4\u4e92\u90fd\u901a\u8fc7\u5b83\u6765\u8fdb\u884c\u5206\u53d1\u548c\u7ba1\u7406\u3002\u6240\u6709\u5e0c\u671b\u4f7f\u7528DBus\u8fdb\u884c\u901a\u8baf\u7684\u8fdb\u7a0b\uff0c\u90fd\u5fc5\u987b\u4e8b\u5148\u8fde\u4e0aDaemon\uff0c\u5e76\u5c06\u81ea\u5df1\u7684\u540d\u5b50\u6ce8\u518c\u5230Daemon\u4e0a\uff0c\u7136\u540e\uff0cDaemon\u4f1a\u4f9d\u7167\u987b\u8981\u628a\u6d88\u606f\u4ee5\u53ca\u6570\u636e\u53d1\u5230\u76f8\u5e94\u7684\u8fdb\u7a0b\u4e2d\u3002<\/p>\n

3.3\u673a\u5236\u7b80\u4ecb<\/p>\n

D-Bus\u673a\u5236\u7684\u91cd\u8981\u6982\u5ff5\u6709\u4ee5\u4e0b\u51e0\u4e2a\uff1a<\/p>\n

a)\u5bf9\u8c61\uff1a\u5bf9\u8c61\u662f\u5c01\u88c5\u540e\u7684\u5339\u914d\u5668\u4e0e\u53cd\u5f39\u51fd\u6570\uff0c\u5b83\u4ee5\u5bf9\u7b49\uff08peer-to-peer\uff09\u5408\u540c\u4f7f\u6bcf\u4f4d\u6d88\u606f\u90fd\u6709\u4e00\u4e2a\u6e90\u5730\u5740\u548c\u4e00\u4e2a\u76ee\u7684\u5730\u5740\u3002\u8fd9\u79cd\u5730\u5740\u53c8\u79f0\u4e3a\u5bf9\u8c61\u8def\u5f84\uff0c\u6216\u5219\u79f0\u4e4b\u4e3a\u603b\u7ebf\u540d\u79f0\u3002\u5bf9\u8c61\u7684\u63d2\u53e3\u662f\u53cd\u5f39\u51fd\u6570\uff0c\u5b83\u4ee5\u7c7b\u4f3cC++\u7684\u865a\u62df\u51fd\u6570\u5b9e\u73b0\u3002\u5f53\u4e00\u4e2a\u8fdb\u7a0b\u6ce8\u518c\u5230\u67d0\u4e2a\u603b\u7ebf\u65f6\uff0c\u90fd\u8981\u521b\u5efa\u76f8\u5e94\u7684\u6d88\u606f\u5bf9\u8c61\u3002<\/p>\n

b)\u6d88\u606f\uff1aD-Bus\u7684\u6d88\u606f\u5206\u4e3a\u8baf\u53f7\uff08signals\uff09\u3001\u65b9\u6cd5\u8c03\u7528\uff08methodcalls\uff09\u3001\u65b9\u6cd5\u8fd4\u56de\uff08methodreturns\uff09\u548c\u9519\u8bef\uff08errors\uff09\u3002\u8baf\u53f7\u662f\u6700\u57fa\u672c\u7684\u6d88\u606f\uff0c\u6ce8\u518c\u7684\u8fdb\u7a0b\u53ef\u7b80\u5355\u5730\u53d1\u9001\u8baf\u53f7\u5230\u603b\u7ebf\u4e0a\u7ea2\u5e3dlinux\u7cfb\u7edf\u4e0b\u8f7d\uff0c\u5176\u4ed6\u8fdb\u7a0b\u901a\u8fc7\u603b\u7ebf\u8bfb\u53d6\u6d88\u606f\u3002\u65b9\u5f0f\u8c03\u7528\u662f\u901a\u8fc7\u603b\u7ebf\u4f20\u9012\u53c2\u6570\uff0c\u6267\u884c\u53e6\u4e00\u4e2a\u8fdb\u7a0b\u63d2\u53e3\u51fd\u6570\u7684\u673a\u5236\uff0c\u7528\u4e8e\u67d0\u4e2a\u8fdb\u7a0b\u63a7\u5236\u53e6\u4e00\u4e2a\u8fdb\u7a0b\u3002\u65b9\u5f0f\u8fd4\u56de\u662f\u6ce8\u518c\u7684\u8fdb\u7a0b\u5728\u6536\u5230\u76f8\u5173\u4fe1\u606f\u540e\uff0c\u624b\u52a8\u4f5c\u51fa\u53cd\u5e94\u7684\u673a\u5236\uff0c\u7531\u53cd\u5f39\u51fd\u6570\u5b9e\u73b0\u3002\u9519\u8bef\u662f\u4fe1\u53f7\u7684\u4e00\u79cd\uff0c\u662f\u6ce8\u518c\u8fdb\u7a0b\u9519\u8bef\u5904\u7406\u673a\u5236\u4e4b\u4e00\u3002<\/p>\n

c)\u670d\u52a1\uff1a\u670d\u52a1\uff08Services\uff09\u662f\u8fdb\u7a0b\u6ce8\u518c\u7684\u5177\u8c61\u3002\u8fdb\u7a0b\u6ce8\u518c\u67d0\u4e2a\u5730\u5740\u540e\uff0c\u5373\u53ef\u83b7\u5f97\u5bf9\u5e94\u603b\u7ebf\u7684\u670d\u52a1\u3002D-Bus\u63d0\u4f9b\u4e86\u670d\u52a1\u67e5\u8be2\u63d2\u53e3\uff0c\u8fdb\u7a0b\u53ef\u901a\u8fc7\u8be5\u63d2\u53e3\u67e5\u8be2\u67d0\u4e2a\u670d\u52a1\u662f\u5426\u5b58\u5728\u3002\u6216\u5219\u5728\u670d\u52a1\u7ed3\u675f\u65f6\u624b\u52a8\u6536\u5230\u6765\u81ea\u7cfb\u7edf\u7684\u6d88\u606f\u3002<\/p>\n

D-Bus\u673a\u5236\u63cf\u8ff0\uff1a<\/p>\n

a)D-Bus\u5177\u5907\u81ea\u8eab\u7684\u5408\u540c\uff0c\u5408\u540c\u57fa\u4e8e\u4e8c\u8865\u7801\u6570\u636e\u8bbe\u8ba1\uff0c\u4e0e\u6570\u636e\u7ed3\u6784\u548c\u7f16\u7801\u5f62\u5f0f\u65e0\u5173\u3002\u8be5\u5408\u540c\u65e0\u9700\u5bf9\u6570\u636e\u8fdb\u884c\u5e8f\u5217\u5316\uff0c\u4fdd\u8bc1\u4e86\u4fe1\u606f\u4f20\u9012\u7684\u9ad8\u6548\u6027\u3002\u65e0\u8bba\u662flibdbus\uff0c\u8fd8\u662fD-Bus\u603b\u7ebf\u5b88\u62a4\u8fdb\u7a0b\uff0c\u5747\u4e0d\u987b\u8981\u592a\u5927\u7684\u7cfb\u7edf\u5f00\u652f\u3002<\/p>\n

b)D-Bus\u672c\u8eab\u662f\u5efa\u7acb\u5728Socket\u673a\u5236\u4e4b\u4e0a\u3002\u771f\u6b63\u7684\u901a\u8baf\u8fd8\u662f\u7531Socket\u6765\u5b8c\u6210\u7684\u3002DBus\u5219\u662f\u5728\u8fd9\u4e4b\u4e0a\uff0c\u62df\u5b9a\u4e86\u4e00\u4e9b\u901a\u8baf\u7684\u5408\u540c\uff0c\u5e76\u63d0\u4f9b\u4e86\u66f4\u521d\u4e00\u5c42\u7684\u63d2\u53e3\uff0c\u4ee5\u66f4\u4fbf\u6377\u5e94\u7528\u7a0b\u5e8f\u4e4b\u95f4\u8fdb\u884c\u6570\u636e\u7684\u4ea4\u4e92\u3002<\/p>\n

c)\u603b\u7ebf\u662fD-Bus\u7684\u8fdb\u7a0b\u95f4\u901a\u8baf\u673a\u5236\uff0c\u4e00\u4e2a\u7cfb\u7edf\u4e2d\u4e00\u822c\u5b58\u5728\u591a\u6761\u603b\u7ebf\uff0c\u8fd9\u79cd\u603b\u7ebf\u7531D-Bus\u603b\u7ebf\u5b88\u62a4\u8fdb\u7a0b\u7ba1\u7406\u3002\u6700\u91cd\u8981\u7684\u603b\u7ebf\u4e3a\u7cfb\u7edf\u603b\u7ebf\uff08SystemBus\uff09\uff0cLinux\u5185\u6838\u5f15\u5bfc\u65f6\uff0c\u8be5\u603b\u7ebf\u5c31\u5df2\u88ab\u653e\u5165\u663e\u5b58\u3002\u53ea\u6709Linux\u5185\u6838\u3001Linux\u684c\u9762\u73af\u5883\u548c\u6743\u9650\u8f83\u9ad8\u7684\u7a0b\u5e8f\u80fd\u591f\u5411\u8be5\u603b\u7ebf\u5199\u5165\u6d88\u606f\uff0c\u501f\u6b64\u4fdd\u969c\u7cfb\u7edf\u5b89\u5168\u6027\uff0c\u907f\u514d\u6709\u6076\u610f\u8fdb\u7a0b\u5192\u5145Linux\u53d1\u9001\u6d88\u606f\u3002\u4f1a\u8bdd\u603b\u7ebf\uff08SessionBuses\uff09\u7531\u666e\u901a\u8fdb\u7a0b\u521b\u5efa\uff0c\u53ef\u540c\u65f6\u5b58\u5728\u591a\u6761\u3002\u4f1a\u8bdd\u603b\u7ebf\u5c5e\u4e8e\u67d0\u4e2a\u8fdb\u7a0b\u79c1\u6709\uff0c\u5b83\u7528\u4e8e\u8fdb\u7a0b\u95f4\u4f20\u9012\u6d88\u606f\u3002<\/p>\n

D-Bus\u901a\u8baf\u6d41\u7a0b\u63cf\u8ff0\uff1a<\/p>\n

l\u65b9\u5f0f\u8c03\u7528\u7684\u901a\u5e38\u6d41\u7a0b\uff1a<\/p>\n

1.\u4f7f\u7528\u4e0d\u540c\u8bed\u8a00\u7ed1\u5b9a\u7684dbus\u9ad8\u5c42\u63d2\u53e3\uff0c\u90fd\u63d0\u4f9b\u4e86\u4e00\u4e9b\u4ee3\u7406\u5bf9\u8c61\uff0c\u8c03\u7528\u5176\u4ed6\u8fdb\u7a0b\u4e0a\u9762\u7684\u8fdc\u7aef\u5bf9\u8c61\u5982\u540c\u662f\u5728\u672c\u5730\u8fdb\u7a0b\u4e2d\u7684\u8c03\u7528\u4e00\u6837\u3002\u5e94\u7528\u8c03\u7528\u4ee3\u7406\u4e0a\u7684\u6280\u5de7ubuntu linux\uff0c\u4ee3\u7406\u5c06\u6784\u9020\u4e00\u4e2a\u65b9\u5f0f\u8c03\u7528\u6d88\u606f\u7ed9\u8fdc\u7aef\u7684\u8fdb\u7a0b\u3002<\/p>\n

2.\u5728DBUS\u7684\u5e95\u5c42\u63d2\u53e3\u4e2d\uff0c\u5e94\u7528\u987b\u8981\u81ea\u5df1\u6784\u9020\u65b9\u5f0f\u8c03\u7528\u6d88\u606f\uff08methodcallmessage\uff09\uff0c\u800c\u4e0d\u80fd\u4f7f\u7528\u4ee3\u7406\u3002<\/p>\n

3.\u65b9\u5f0f\u8c03\u7528\u6d88\u606f\u4e0a\u9762\u7684\u5185\u5bb9\u6709\uff1a\u76ee\u7684\u8fdb\u7a0b\u7684busname\uff0c\u6280\u5de7\u7684\u540d\u5b50\uff0c\u6280\u5de7\u7684\u53c2\u6570\uff0c\u76ee\u7684\u8fdb\u7a0b\u7684\u5bf9\u8c61\u8def\u5f84\uff0c\u4ee5\u53ca\u53ef\u9009\u7684\u63d2\u53e3\u540d\u79f0\u3002<\/p>\n

4.\u65b9\u5f0f\u8c03\u7528\u6d88\u606f\u662f\u53d1\u9001\u5230busdaemon\u4e2d\u7684\u3002<\/p>\n

5.busdaemon\u67e5\u627e\u76ee\u6807\u7684busname\uff0c\u5047\u82e5\u627e\u5230\uff0c\u5c31\u628a\u8fd9\u4e2a\u65b9\u5f0f\u53d1\u9001\u5230\u8be5\u8fdb\u7a0b\u4e2d\uff0c\u5426\u5219\uff0cdaemon\u4f1a\u5f62\u6210\u9519\u8bef\u6d88\u606f\uff0c\u4f5c\u4e3a\u5e94\u7b54\u6d88\u606f\u7ed9\u53d1\u9001\u8fdb\u7a0b\u3002<\/p>\n

6.\u76ee\u6807\u8fdb\u7a0b\u89e3\u5f00\u6d88\u606f\uff0c\u5728dbus\u5e95\u5c42\u63d2\u53e3\u4e2d\uff0c\u4f1a\u7acb\u523b\u8c03\u7528\u65b9\u5f0f\uff0c\u4e4b\u540e\u53d1\u9001\u65b9\u5f0f\u7684\u5e94\u7b54\u6d88\u606f\u7ed9daemon\u3002\u5728dbus\u9ad8\u5c42\u63d2\u53e3\u4e2d\uff0c\u4f1a\u5148\u68c0\u67e5\u5bf9\u8c61\u8def\u5f84\uff0c\u63d2\u53e3\uff0c\u6280\u5de7\u540d\u79f0\uff0c\u4e4b\u540e\u628a\u5b83\u8f6c\u6362\u6210\u5bf9\u5e94\u7684\u5bf9\u8c61\uff08\u5982GObject\uff0cQT\u4e2d\u7684QObject\u7b49\uff09\u7684\u65b9\u5f0f\uff0c\u4e4b\u540e\u518d\u5c06\u5e94\u7b54\u7ed3\u679c\u8f6c\u6362\u6210\u5e94\u7b54\u6d88\u606f\u53d1\u7ed9daemon\u3002<\/p>\n

7.busdaemon\u63a5\u53d7\u5230\u5e94\u7b54\u6d88\u606f\uff0c\u5c06\u628a\u5e94\u7b54\u6d88\u606f\u76f4\u63a5\u53d1\u7ed9\u53d1\u51fa\u8c03\u7528\u6d88\u606f\u7684\u8fdb\u7a0b\u3002<\/p>\n

8.\u5e94\u7b54\u6d88\u606f\u4e2d\u53ef\u4ee5\u5bbd\u5bb9\u597d\u591a\u8fd4\u56de\u503c\uff0c\u4e5f\u53ef\u4ee5\u6807\u793a\u4e00\u4e2a\u9519\u8bef\u53d1\u751f\uff0c\u5f53\u4f7f\u7528\u7ed1\u5b9a\u65f6\uff0c\u5e94\u7b54\u6d88\u606f\u5c06\u8f6c\u6362\u4e3a\u4ee3\u7406\u5bf9\u8c61\u7684\u8fd4\u56de\u503c\uff0c\u6216\u5219\u6b65\u5165\u5f02\u5e38\u3002<\/p>\n

busdaemon\u4e0d\u5bf9\u6d88\u606f\u91cd\u65b0\u6392\u5e8f\uff0c\u5047\u5982\u53d1\u9001\u4e86\u4e24\u6761\u6d88\u606f\u5230\u540c\u4e00\u4e2a\u8fdb\u7a0b\uff0c\u5979\u4eec\u5c06\u6839\u636e\u53d1\u9001\u6b21\u5e8f\u63a5\u53d7\u5230\u3002\u63a5\u53d7\u8fdb\u7a0b\u5e76\u987b\u8981\u4f9d\u7167\u6b21\u5e8f\u53d1\u51fa\u5e94\u7b54\u6d88\u606f\uff0c\u6bd4\u5982\u5728\u591a\u7ebf\u7a0b\u4e2d\u5904\u7406\u90a3\u4e9b\u6d88\u606f\uff0c\u5e94\u7b54\u6d88\u606f\u7684\u53d1\u51fa\u662f\u6ca1\u6709\u6b21\u5e8f\u7684\u3002\u6d88\u606f\u90fd\u6709\u4e00\u4e2a\u5e8f\u5217\u53f7\u53ef\u4ee5\u4e0e\u5e94\u7b54\u6d88\u606f\u8fdb\u884c\u914d\u5bf9\u3002<\/p>\n

l\u8baf\u53f7\u7684\u901a\u5e38\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n

1.\u5f53\u4f7f\u7528dbus\u5e95\u5c42\u63d2\u53e3\u65f6\uff0c\u8baf\u53f7\u987b\u8981\u5e94\u7528\u81ea\u5df1\u521b\u5efa\u548c\u53d1\u9001\u5230daemon\uff0c\u4f7f\u7528dbus\u9ad8\u5c42\u63d2\u53e3\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f8\u5173\u5bf9\u8c61\u8fdb\u884c\u53d1\u9001\uff0c\u5982Glib\u4e0a\u9762\u63d0\u4f9b\u7684\u8baf\u53f7\u89e6\u53d1\u673a\u5236\u3002<\/p>\n

2.\u8baf\u53f7\u5305\u542b\u7684\u5185\u5bb9\u6709\uff1a\u8baf\u53f7\u7684\u63d2\u53e3\u540d\u79f0\uff0c\u8baf\u53f7\u540d\u79f0\uff0c\u53d1\u9001\u8fdb\u7a0b\u7684busname\uff0c\u4ee5\u53ca\u5176\u4ed6\u53c2\u6570\u3002<\/p>\n

3.\u4efb\u4f55\u8fdb\u7a0b\u90fd\u53ef\u4ee5\u6839\u636e\u201dmatchrules\u201d\u6ce8\u518c\u76f8\u5173\u7684\u8baf\u53f7\uff0cdaemon\u6709\u4e00\u5f20\u6ce8\u518c\u7684\u5217\u8868\u3002<\/p>\n

4.daemon\u6d4b\u91cf\u8baf\u53f7\uff0c\u51b3\u5b9a\u4ec0\u4e48\u8fdb\u7a0b\u5bf9\u8fd9\u4e2a\u8baf\u53f7\u611f\u5174\u8da3\uff0c\u4e4b\u540e\u628a\u8baf\u53f7\u53d1\u9001\u7ed9\u8fd9\u79cd\u8fdb\u7a0b\u3002<\/p>\n

5.\u6bcf\u4f4d\u8fdb\u7a0b\u6536\u5230\u8baf\u53f7\u540e\uff0c\u5047\u5982\u662f\u4f7f\u7528\u4e86dbus\u9ad8\u5c42\u63d2\u53e3\uff0c\u53ef\u4ee5\u9009\u62e9\u89e6\u53d1\u4ee3\u7406\u5bf9\u8c61\u4e0a\u7684\u8baf\u53f7\u3002\u5047\u5982\u662fdbus\u5e95\u5c42\u63d2\u53e3\uff0c\u987b\u8981\u68c0\u6d4b\u53d1\u9001\u8005\u540d\u79f0\u548c\u8baf\u53f7\u540d\u79f0\uff0c\u4e4b\u540e\u51b3\u5b9a\u5982\u4f55\u505a\u3002<\/p>\n

3.4\u57fa\u4e8eGlib\u7684\u6837\u4f8b3.4.1\u5bf9\u6bd4Glib\u7684\u7c7b\u578b\u8bf4\u660e<\/p>\n

dbus\u548cglib\u7684\u6570\u636e\u7c7b\u578b\u6620\u5c04\u5982\u4e0b\uff1a<\/p>\n

D-Busbasictype<\/p>\n

GType<\/p>\n

Freefunction<\/p>\n

Notes<\/p>\n

BYTE<\/p>\n

G_TYPE_UCHAR<\/p>\n

BOOLEAN<\/p>\n

G_TYPE_BOOLEAN<\/p>\n

INT16<\/p>\n

G_TYPE_INT<\/p>\n

WillbechangedtoaG_TYPE_INT16once<\/p>\n

GLibhasit<\/p>\n

UINT16<\/p>\n

G_TYPE_UINT<\/p>\n

WillbechangedtoaG_TYPE_UINT16once<\/p>\n

GLibhasit<\/p>\n

INT32<\/p>\n

G_TYPE_INT<\/p>\n

WillbechangedtoaG_TYPE_INT32once<\/p>\n

GLibhasit<\/p>\n

UINT32<\/p>\n

G_TYPE_UINT<\/p>\n

WillbechangedtoaG_TYPE_UINT32once<\/p>\n

GLibhasit<\/p>\n

INT64<\/p>\n

G_TYPE_GINT64<\/p>\n

UINT64<\/p>\n

G_TYPE_GUINT64<\/p>\n

DOUBLE<\/p>\n

G_TYPE_DOUBLE<\/p>\n

STRING<\/p>\n

G_TYPE_STRING<\/p>\n

g_free<\/p>\n

OBJECT_PATH<\/p>\n

DBUS_TYPE_G_PROXY<\/p>\n

g_object_unref<\/p>\n

Thereturnedproxydoesnothaveaninterfaceset;use<\/p>\n

dbus_g_proxy_set_interfacetoinvokemethods<\/p>\n

Containertypemappings<\/p>\n

dbus\u6570\u636e\u4e5f\u6709\u5bbd\u5bb9\u5668\u7c7b\u578b\uff0c\u50cfDBUS_TYPE_ARRAY\u548cDBUS_TYPE_STRUCT\uff0cdbus\u7684\u6570\u636e\u7c7b\u578b\u53ef\u4ee5\u662f\u5d4c\u5957\u7684\uff0c\u5982\u6709\u4e00\u4e2a\u94fe\u8868\uff0c\u5185\u5bb9\u662f\u5b57\u7b26\u4e32\u7684\u5b57\u6bb5\u96c6\u5408\u3002<\/p>\n

\u7136\u800c\uff0c\u5e76\u4e0d\u662f\u6240\u6709\u7684\u7c7b\u578b\u90fd\u6709\u666e\u901a\u7684\u4f7f\u7528\uff0cDBUS_TYPE_STRUCT\u5e94\u5f53\u53ef\u4ee5\u5bbd\u5bb9\u975e\u57fa\u672c\u7c7b\u578b\u7684\u6570\u636e\u7c7b\u578b\u3002glib\u7ed1\u5b9a\u5c1d\u8bd5\u4f7f\u7528\u6bd4\u8f83\u663e\u8457\u7684\u5f62\u5f0f\u8fdb\u884c\u7533\u660e\u3002<\/p>\n

D-Bustypesignature<\/p>\n

Description<\/p>\n

GType<\/p>\n

Ctypedef<\/p>\n

Freefunction<\/p>\n

Notes<\/p>\n

as<\/p>\n

Arrayofstrings<\/p>\n

G_TYPE_STRV<\/p>\n

char**<\/p>\n

g_strfreev<\/p>\n

Genericvaluecontainer<\/p>\n

G_TYPE_VALUE<\/p>\n

GValue*<\/p>\n

g_value_unset<\/p>\n

Thecallingconventionsforvaluesexpectthatmethodcallershave<\/p>\n

allocatedreturnvalues;seebelow.<\/p>\n

\u540c\u65f6\u5b9a\u4e49\u4e86\u65b0\u7684\u5b57\u6bb5\u7c7b\u578b\u96c6\u5408\u3002<\/p>\n

D-Bustypesignature<\/p>\n

Description<\/p>\n

GType<\/p>\n

Ctypedef<\/p>\n

Freefunction<\/p>\n

Notes<\/p>\n

ay<\/p>\n

Arrayofbytes<\/p>\n

DBUS_TYPE_G_BYTE_ARRAY<\/p>\n

GArray*<\/p>\n

g_array_free<\/p>\n

au<\/p>\n

Arrayofuint<\/p>\n

DBUS_TYPE_G_UINT_ARRAY<\/p>\n

GArray*<\/p>\n

g_array_free<\/p>\n

ai<\/p>\n

Arrayofint<\/p>\n

DBUS_TYPE_G_INT_ARRAY<\/p>\n

GArray*<\/p>\n

g_array_free<\/p>\n

ax<\/p>\n

Arrayofint64<\/p>\n

linux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u4fe1_linux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u4fe1_linux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u4fe1<\/p>\n

DBUS_TYPE_G_INT64_ARRAY<\/p>\n

GArray*<\/p>\n

g_array_free<\/p>\n

at<\/p>\n

Arrayofuint64<\/p>\n

DBUS_TYPE_G_UINT64_ARRAY<\/p>\n

GArray*<\/p>\n

g_array_free<\/p>\n

ad<\/p>\n

Arrayofdouble<\/p>\n

DBUS_TYPE_G_DOUBLE_ARRAY<\/p>\n

GArray*<\/p>\n

g_array_free<\/p>\n

ab<\/p>\n

Arrayofboolean<\/p>\n

DBUS_TYPE_G_BOOLEAN_ARRAY<\/p>\n

GArray*<\/p>\n

g_array_free<\/p>\n

\u5b9a\u4e49\u4e86\u5b57\u5178\u7c7b\u578b<\/p>\n

D-Bustypesignature<\/p>\n

Description<\/p>\n

GType<\/p>\n

Ctypedef<\/p>\n

Freefunction<\/p>\n

Notes<\/p>\n

a{ss}<\/p>\n

Dictionarymappingstringstostrings<\/p>\n

DBUS_TYPE_G_STRING_STRING_HASHTABLE<\/p>\n

GHashTable*<\/p>\n

g_hash_table_destroy<\/p>\n

3.4.2\u4f7f\u7528\u6837\u4f8b<\/p>\n

l\u7f51\u4e0a\u6709\u4e00\u4e2a\u53ebd-feet\u7684python\u7a0b\u5e8f\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u5b83\u6765\u89c2\u5bdf\u7cfb\u7edf\u4e2d\u7684dbus\u4e16\u754c\u3002<\/p>\n

\u56fe1\u3001\u7531d-feet\u89c2\u5bdf\u5230\u7684D-Bus\u4e16\u754c<\/p>\n

D-Bus\u662f\u4e00\u4e2a\u7a0b\u5e8f\u3002\u5b83\u63d0\u4f9b\u4e86API\u3002\u4f46\u6211\u4eec\u901a\u5e38\u4e0d\u4f1a\u76f4\u63a5\u4f7f\u7528dbus\u7684\u63d2\u53e3\u3002dbus-glib\u662fGTK\u7248\u672c\u7684dbus\u63d2\u53e3\u5c01\u88c5\u3002\u672c\u6587\u5047\u5b9a\u8bfb\u8005\u5b89\u88c5\u4e86dbus-glib\uff0c\u6211\u5b89\u88c5\u7684\u662fdbus-glib-0.76\u3002\u65c1\u8fb9\u90fd\u4f1a\u770b\u89c1\uff0c\u901a\u8fc7python\u64cd\u7eb5dbus\u662f\u591a\u4e48\u7b80\u5355\u3002<\/p>\n

l\u4ee5hello-dbus3-0.1.tar.gz\u4e3a\u4f8b\uff08\u9644\u8868\u6709\u539f\u4e8b\u4f8b\u94fe\u63a5\uff09\uff0c\u8fd9\u662f\u4e00\u4e2aautotool\u5de5\u7a0b\uff0c\u4f60\u4eec\u89e3\u5305\u540e\uff0c\u6267\u884c\uff1a<\/p>\n

.\/autogen.sh<\/p>\n

.\/configure<\/p>\n

make<\/p>\n

\u4e4b\u540e\u5728src\u76ee\u5f55\u8fd0\u884c\uff1a<\/p>\n

.\/example-service<\/p>\n

\u8fd9\u65f6\u518d\u8fd0\u884cd-feet\uff0c\u8054\u63a5sessionbus\uff0c\u5728\u201cBusName\u201d\u7a97\u53e3\u4f1a\u89c1\u5230\u4e00\u4e2a\u53eb\u201corg.fmddlmyy.Test\u201d\u8fde\u63a5\u540d\u3002<\/p>\n

\u56fe2\u3001\u63d0\u4f9bD-Bus\u670d\u52a1\u7684org.fmddlmyy.Test<\/p>\n

\u9009\u62e9\u201corg.fmddlmyy.Test\u201d\uff0c\u5728\u5de6\u8fb9\u7a97\u53e3\u70b9\u51fb\u5c55\u5f00\u201cObjectPaths\u201d->\u201c\/TestObj\u201d->\u201cInterfaces\u201d->\u201corg.fmddlmyy.Test.Basic\u201d->\u201cMethods\u201d\uff0c\u53ef\u4ee5\u770b\u89c1\u4e00\u4e2aAdd\u6280\u5de7\u3002\u53cc\u51fbAdd\u65b9\u5f0f\uff0c\u5f39\u51fa\u4e0b\u8fb9\u8fd9\u4e2a\u5bf9\u8bdd\u6846\uff1a<\/p>\n

linux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u4fe1_linux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u4fe1_linux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u4fe1<\/p>\n

\u56fe3\u3001\u901a\u8fc7D-Bus\u63d2\u53e3\u4f30\u7b971+2=3<\/p>\n

\u5728Parameters\u7a97\u53e3\u8f93\u5165\u201c1,2\u201d\uff0c\u70b9\u51fb\u201cExecute\u201d\u6309\u94ae\uff0c\u4e4b\u540e\u5728\u201cOutput\u201d\u7a97\u53e3\u6211\u4eec\u770b\u89c1\u4e86\u8f93\u51fa\u7ed3\u679c\u3002\u6211\u4eec\u521a\u624d\u521b\u5efa\u4e86\u4e00\u4e2adbus\u670d\u52a1\u5e76\u8c03\u7528\u4e86\u5b83\u3002<\/p>\n

3.4.3\u4e3b\u8981\u6d41\u7a0b<\/p>\n

l\u901a\u8fc7dbus-binding-tool\u5de5\u5177\uff0c\u53ef\u4ee5\u5c06xml\u5b9a\u4e49\u7684\u63d2\u53e3\u6587\u4ef6\u8f6c\u6362\u6210c\u8bed\u8a00\u7684\u5934\u6587\u4ef6\u3002<\/p>\n

\u6bd4\u5982\uff1adbus-binding-tool--prefix=test_obj--mode=glib-server--output=testDbus-glue.h.\/testDbus.xml<\/p>\n

l\u5f15\u5165\u751f\u6210\u7684\u5934\u6587\u4ef6\uff0c\u5b9e\u73b0\u63d2\u53e3\u51fd\u6570\u3002<\/p>\n

l\u7528dbus_g_bus_get\u5f97\u5230sessionbus\u7684\u8054\u63a5<\/p>\n

l\u5728\u8fd9\u4e2a\u8054\u63a5\u4e0a\u7528dbus_g_proxy_new_for_name\u51fd\u6570\u83b7\u5f97\u5230\u62e5\u6709\u6307\u5b9a\u516c\u5171\u540d\u7684\u8054\u63a5\u7684\u6307\u5b9a\u5bf9\u8c61\u7684\u6307\u5b9a\u63d2\u53e3\u7684\u4ee3\u7406<\/p>\n

l\u6700\u540e\uff0c\u7528dbus_g_proxy_call\u51fd\u6570\u901a\u8fc7\u63d2\u53e3\u4ee3\u7406\u8c03\u7528\u63d2\u53e3\u63d0\u4f9b\u7684\u65b9\u5f0f\u3002<\/p>\n

3.4.4\u4e3b\u8981\u63d2\u53e3<\/p>\n

l\u901a\u8fc7glib\u7684\u4ee3\u7406proxy\u8c03\u7528\u65b9\u5f0f<\/p>\n

nFunctionforsynchronouslyinvokingamethodandreceivingreplyvalues<\/p>\n

gbooleandbus_g_proxy_call(DBusGProxy*proxy,<\/p>\n

constchar*method,<\/p>\n

GError**error,<\/p>\n

GTypefirst_arg_type,<\/p>\n

...);<\/p>\n

nFunctionforsynchronouslyinvokingamethodandreceivingreplyvalues.<\/p>\n

gbooleandbus_g_proxy_call_with_timeout(DBusGProxy*proxy,<\/p>\n

constchar*method,<\/p>\n

inttimeout,<\/p>\n

GError**error,<\/p>\n

GTypefirst_arg_type,<\/p>\n

...);<\/p>\n

nSendsamethodcallmessageaswithdbus_g_proxy_begin_call(),butdoesnotaskforareplyorallowyoutoreceiveone.<\/p>\n

voiddbus_g_proxy_call_no_reply(DBusGProxy*proxy,<\/p>\n

constchar*method,<\/p>\n

GTypefirst_arg_type,<\/p>\n

...);<\/p>\n

nAsynchronouslyinvokesamethodonaremoteinterface.<\/p>\n

DBusGProxyCall*dbus_g_proxy_begin_call(DBusGProxy*proxy,<\/p>\n

constchar*method,<\/p>\n

DBusGProxyCallNotifynotify,<\/p>\n

gpointeruser_data,<\/p>\n

GDestroyNotifydestroy,<\/p>\n

GTypefirst_arg_type,<\/p>\n

...);<\/p>\n

nAsynchronouslyinvokesamethodonaremoteinterface.<\/p>\n

DBusGProxyCall*dbus_g_proxy_begin_call_with_timeout<\/p>\n

(DBusGProxy*proxy,<\/p>\n

constchar*method,<\/p>\n

DBusGProxyCallNotifynotify,<\/p>\n

gpointeruser_data,<\/p>\n

GDestroyNotifydestroy,<\/p>\n

inttimeout,<\/p>\n

GTypefirst_arg_type,<\/p>\n

linux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u4fe1_linux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u4fe1_linux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u4fe1<\/p>\n

...);<\/p>\n

nCollectstheresultsofamethodcall.<\/p>\n

gbooleandbus_g_proxy_end_call(DBusGProxy*proxy,<\/p>\n

DBusGProxyCall*call,<\/p>\n

GError**error,<\/p>\n

GTypefirst_arg_type,<\/p>\n

...);<\/p>\n

nCancelsapendingmethodcall.<\/p>\n

voiddbus_g_proxy_cancel_call(DBusGProxy*proxy,<\/p>\n

DBusGProxyCall*call);<\/p>\n

\u6ce8\uff1a\u51fd\u6570\u8bf4\u660e\u94fe\u63a5<\/p>\n

3.5\u57fa\u4e8eQt\u7684\u6837\u4f8b3.5.1\u5bf9\u6bd4QtDBus<\/p>\n

\u6ce8\u610f\uff1aQt\u6e90\u7801\u7f16\u8bd1\u65f6\uff0c\u987b\u8981\u4fdd\u8bc1\u7cfb\u7edf\u4e2d\u65e9\u5df2\u5b89\u88c5\u597ddbus\uff0c\u4e4b\u540eQt\u7f16\u8bd1\u9009\u9879\u4e2d\u8981\u9009\u652f\u6301dbus\uff0c\u8fd9\u6837\u4f1a\u5c31\u4f1a\u751f\u6210LibQtDBus.so\u7b49\u76f8\u5173\u5e93\u6587\u4ef6\u3002<\/p>\n

Qt\u7684example\u4e2d\u6709\u51e0\u4e2a\u53cd\u4f8b\uff0c\u8fd9\u513f\u5c31\u4e0d\u6df1\u7a76\u4e86\u3002<\/p>\n

3.6\u76f4\u63a5\u8c03\u7528dbus\u63d2\u53e3<\/p>\n

\u4f7f\u7528\u65b9\u6cd5\u7c7b\u4f3c\uff1a<\/p>\n

l\u7528dbus_bus_get\u83b7\u53d6sessionbus\u7684\u8054\u63a5<\/p>\n

l\u901a\u8fc7sessionbus\u7684\u8054\u63a5\u7ed1\u5b9a\u7b49\u5f85\u6570\u636e<\/p>\n

l\u53d1\u9001\u6570\u636e<\/p>\n

n\u5f02\u6b65\u51fd\u6570\u8c03\u7528\uff1adbus_connection_send<\/p>\n

n\u540c\u6b65\u51fd\u6570\u8c03\u7528\uff1adbus_connection_send_with_reply<\/p>\n

3.7\u4f18\u70b9<\/p>\n

\u4f4e\u5ef6\u540e\uff0c\u4f4e\u5f00\u652f\uff0c\u9ad8\u53ef\u7528\u6027\uff1a<\/p>\n

1)\u4f4e\u5ef6\u540e\uff1aDBus\u4e00\u5f00\u59cb\u5c31\u662f\u62ff\u6765\u8bbe\u8ba1\u6210\u9632\u6b62\u6765\u56de\u4f20\u9012\u548c\u5bb9\u8bb8\u5f02\u6b65\u64cd\u4f5c\u7684\u3002\u56e0\u800c\u5373\u4f7f\u5728Application\u548cDaemon\u4e4b\u95f4\u662f\u901a\u8fc7socket\u5b9e\u73b0\u7684\uff0c\u5e76\u4e14\u53c8\u9664\u53bb\u4e86socket\u7684\u5faa\u73af\u7b49\u5f85\uff0c\u4fdd\u8bc1\u4e86\u64cd\u4f5c\u7684\u5b9e\u65f6\u9ad8\u6548\u3002<\/p>\n

2)\u4f4e\u5f00\u652f\uff1aDBus\u4f7f\u7528\u4e00\u4e2a\u4e8c\u8865\u7801\u7684\u5408\u540c\uff0c\u4e0d\u987b\u8981\u8f6c\u5316\u6210\u50cfXML\u8fd9\u6837\u7684\u6587\u672c\u683c\u5f0f\u3002\u7531\u4e8eDBus\u662f\u4e3b\u8981\u62ff\u6765\u673a\u5668\u5185\u90e8\u7684IPC,\u800c\u4e0d\u662f\u4e3a\u4e86\u7f51\u8def\u4e0a\u7684IPC\u673a\u5236\u800c\u6253\u7b97\u7684.\u6240\u4ee5\u5b83\u624d\u624d\u80fd\u5728\u672c\u673a\u5185\u90e8\u8fbe\u5230\u6700\u4f18\u7597\u6548\u3002<\/p>\n

3)\u9ad8\u53ef\u7528\u6027\uff1aDBus\u662f\u57fa\u4e8e\u6d88\u606f\u673a\u5236\u800c\u4e0d\u662f\u5b57\u8282\u6d41\u673a\u5236\u3002\u5b83\u80fd\u624b\u52a8\u7ba1\u7406\u4e00\u5927\u5806\u56f0\u96be\u7684IPC\u95ee\u9898\u3002\u540c\u6837\u7684\uff0cDBus\u5e93\u88ab\u8bbe\u8ba1\u6765\u8ba9\u7a0b\u5e8f\u5458\u624d\u80fd\u4f7f\u7528\u5979\u4eec\u65e9\u5df2\u5199\u597d\u7684\u4ee3\u7801\u3002\u800c\u4e0d\u4f1a\u8ba9\u5979\u4eec\u820d\u5f03\u65e9\u5df2\u5199\u597d\u7684\u4ee3\u7801\uff0c\u88ab\u8feb\u901a\u8fc7\u5b66\u4e60\u65b0\u7684IPC\u673a\u5236\u6765\u6309\u7167\u65b0\u7684IPC\u7279\u70b9\u91cd\u753b\u8fd9\u79cd\u4ee3\u7801\u3002<\/p>\n

4AF_BUS\u7b80\u4ecb<\/p>\n

\u5728Genivi\u5e93\u4e2d\u4ee5\u8865\u4e01\u7684\u65b9\u5f0f\u5b58\u5728\uff0c\u5206\u522b\u5bf9linux,glib,dbus\u8fdb\u884c\u4e86\u90e8\u4efd\u66f4\u6539\u3002<\/p>\n

\u76ee\u524d\u6ca1\u6709\u4ea7\u751fdemo\u3002<\/p>\n

5\u6838\u9ad8\u57fa\u5c0f\u7ed3<\/p>\n

\u6309\u7167\u76ee\u524d\u73b0\u6709\u8d44\u6599\u5256\u6790\uff0c\u57fa\u7840\u7684Linux\u8fdb\u7a0b\u95f4\u901a\u8baf\u65b9\u6cd5\u53ea\u80fd\u9017\u7559\u5728\u5b57\u7b26\u5e8f\u5217\u4e0a\uff0c\u987b\u8981\u8fdb\u4e00\u6b65\u5c01\u88c5\u80fd\u591f\u6ee1\u8db3\u4f7f\u7528\u9700\u6c42\u3002\u800cD-Bus\u5219\u57fa\u4e8e\u6d88\u606f\u5c01\u88c5\u4e86\u5e95\u5c42\u5b9e\u73b0\uff0c\u63d2\u53e3\u53c8\u6709glib\u3001qt\u7b49\u8fdb\u884c\u518d\u6b64\u5305\u88c5\uff0c\u5b9e\u73b0\u4e0a\u80fd\u505a\u5230\u4f4e\u5ef6\u540e\uff0c\u4f4e\u5f00\u652f\uff0c\u9ad8\u53ef\u7528\u6027\uff0c\u90fd\u662f\u5176\u4f7f\u7528\u4f18\u70b9\u3002<\/p>\n

\u672a\u6765\u4f7f\u7528d-bus\u8fd8\u987b\u8981\u7559\u5fc3\u7684\u51e0\u70b9\uff1a<\/p>\n

l\u5b83\u5e95\u5c42\u662f\u7528socket\u5c01\u88c5\u7684\uff0c\u662f\u5426\u53ef\u4ee5\u8f7b\u6613\u7684\u5728\u591a\u4e3b\u673a\u95f4\u901a\u8baf\uff0c\u600e\u6837\u914d\u7f6e\u7b49\u3002<\/p>\n

l\u5728\u5927\u6570\u636e\u91cf\u4e0b\uff0c\u662f\u5426\u80fd\u591f\u6ee1\u8db3\u6211\u4eec\u7684\u9700\u6c42\u3002<\/p>\n

l\u4ed6\u81ea\u8eab\u673a\u5236\u548c\u6211\u4eec\u5e94\u7528\u7684\u8fdb\u7a0b\u7ebf\u7a0b\u4fdd\u62a4\u4e4b\u95f4\u662f\u5426\u6709\u6ce8\u610f\u7684\u5730\u65b9\u3002<\/p>\n

6\u9644\u88686.1D-Bus\u76f8\u5173\u8d44\u6599<\/p>\n

\u4e00\u4e9b\u57fa\u672c\u6982\u5ff5\u7684\u89e3\u91ca\u548c\u7ffb\u8bd1\uff1a<\/p>\n

\u4e00\u4e2a\u5b8c\u6574\u7684DBus\u5b66\u4e60\u6559\u7a0b(\u5f3a\u70c8\u63a8\u8350\uff0c\u5199\u5f97\u76f8\u5f53\u7684\u5168)\uff1a<\/p>\n

\u4e24\u4e2aDBus\u7684\u5b8c\u6574\u793a\u4f8b\uff0c\u76f8\u5f53\u6709\u53c2\u8003\u4ef7\u503c<\/p>\n

DBus\u5b98\u65b9\u7f51\u7ad9\uff0c\u6700\u539f\u6ecb\u539f\u5473\u7684DBus\u5b66\u4e60\u5185\u5bb9<\/p>\n

\u8d44\u6599\u63a8\u8350\u51fa\u5904\uff1a<\/p>\n

6.2D-Bus\u5b89\u88c5<\/p>\n

Ubuntu\u4e0b\u5b89\u88c5D-Bus\u5305\uff1a<\/p>\n

\u8981\u5148\u88c5\u4e00\u4e0blibdbus\uff0c\u6267\u884c\u4e00\u4e0b\u4ee5\u4e0b\u53e5\u5b50\u5c31OK\u4e86<\/p>\n

sudoapt-getinstalllibgtk2.0-dev<\/p>\n

sudoapt-getinstalllibdbus-glib-1-dev<\/p>\n

\/\/\u53e6\u53ef\u4ee5\u5b89\u88c5\u4e00\u4e0b\u4e0b\u8fb9\u8fd9\u4e2a\u5de5\u5177<\/p>\n

sudoapt-getinstalld-feet<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6b64\u5904\u53ea\u662f\u7b80\u5355\u4ecb\u7ecd\u4e86Linux\u5185\u6838\u63d0\u4f9b\u7684\u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684\u65b9\u5f0f\uff0c\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u53ef\u4ee5\u53c2\u7167\u300alinux\u73af\u5883\u8fdb\u7a0b\u95f4\u901a\u4fe1(\u5168)\u300b2.\u684c\u9762\u7a0b\u5e8f\u4e0e\u5185\u6838\u6216\u8005\u5b88\u62a4\u8fdb\u7a0b\u7684\u901a\u4fe1\u3002c)\u603b\u7ebf\u662fD-Bus\u7684\u8fdb\u7a0b\u95f4\u901a\u4fe1\u673a\u5236\uff0c\u4e00\u4e2a\u7cfb\u7edf\u4e2d\u901a\u5e38\u5b58\u5728\u591a\u6761\u603b\u7ebf\uff0c\u8fd9\u4e9b\u603b\u7ebf\u7531D-Bus\u603b\u7ebf\u5b88\u62a4\u8fdb\u7a0b\u7ba1\u7406\u3002<\/p>\n","protected":false},"author":1,"featured_media":289508,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-289507","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/289507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=289507"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/289507\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/289508"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=289507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=289507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=289507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}