{"id":165959,"date":"2013-01-16T08:08:03","date_gmt":"2013-01-16T04:08:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=165959"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=165959","title":{"rendered":"<span class=\"post_title\">\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 D-Bus \u0432 \u0432\u0435\u0431-\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043c\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0449\u0435\u0439, \u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0443\u044f\u0441\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u043c <a href=\"http:\/\/habrahabr.ru\/post\/144611\/\">DRY<\/a> (Don&#8217;t Repeat Yourself \u2014 \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0439\u0441\u044f), \u043f\u0440\u0438\u043d\u044f\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043e\u0431\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c.<\/p>\n<p>  \u041a \u043c\u043e\u0434\u0443\u043b\u044e \u0431\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f:  <\/p>\n<ul>\n<li>\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432;<\/li>\n<li>\u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u00ab\u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0433\u043e\u00bb \u043a\u043e\u0434\u0430;<\/li>\n<li>\u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b.<\/li>\n<\/ul>\n<p><a name=\"habracut\"><\/a><br \/>  \u041e\u0433\u043e\u0432\u043e\u0440\u044e\u0441\u044c, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0430 PHP \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 Apache \u043f\u043e\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c Linux. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0431\u044b\u043b\u0438: \u00ab\u043d\u0430 \u0447\u0451\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c?\u00bb \u0438 \u00ab\u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043c\u043e\u0434\u0443\u043b\u044e \u0438\u0437 PHP-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432?\u00bb. \u0410\u043d\u0430\u043b\u0438\u0437 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f, \u0431\u044b\u043b \u043f\u0440\u043e\u0432\u0435\u0434\u0451\u043d \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043d\u0430\u0448\u0438\u0445 \u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0439, \u0437\u043d\u0430\u043d\u0438\u0439 \u0438 \u043e\u043f\u044b\u0442\u0430. <br \/>  \u0411\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043e 3 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430: <\/p>\n<ol>\n<li>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u0432\u0438\u0434\u0435 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043d\u0430 PHP \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0438\u0437 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f CUrl \u0438\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e SOAP. \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u2014 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0438\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430, \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b (\u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435), \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u0438 \u043f\u0430\u0440\u0430\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445.<\/li>\n<li>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u0432\u0438\u0434\u0435 FastCGI-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u041a \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u043c \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043d\u0435\u0441\u0442\u0438: \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0430 C\/C++, \u0447\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u043e \u0431\u044b \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u0442\u044b \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435. \u041e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043c\u043e\u0434\u0443\u043b\u044e \u0438\u0437 PHP-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u043a\u0435\u0442\u043e\u0432 Unix, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0437\u0430\u0442\u0440\u0430\u0442 \u043d\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u0441\u0435\u0442\u0438 (\u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435).<\/li>\n<li>\u041f\u043e\u043c\u0438\u043c\u0438\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432, \u043d\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u043b\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u0435\u0436\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043d\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f (IPC) D-Bus, \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0432 Linux \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 D-Bus, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0441\u0442\u044c, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u043e\u0441\u0442\u044c, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a-\u043e\u0431\u0451\u0440\u0442\u043e\u043a, \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043d\u0430\u043c \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0438 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0438\u043c\u0438 \u043d\u0430\u0448\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e \u0441\u0443\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043f\u0440\u0438\u0432\u0435\u043b\u043e \u0431\u044b \u043d\u0430\u0441 \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0430 D-Bus. \u0414\u0430\u043b\u0435\u0435, \u0432\u0441\u0442\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441 \u043e \u0432\u044b\u0437\u043e\u0432\u0430\u0445 \u043c\u043e\u0434\u0443\u043b\u044f \u0438\u0437 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0433\u043e PHP-\u043a\u043e\u0434\u0430. \u0412 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043d\u0430\u043c \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u043e\u0441\u044c \u0434\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0445 D-Bus \u043d\u0430 PHP: \u043e\u0442 <a href=\"http:\/\/pecl.php.net\/package\/DBus\">Pecl<\/a> \u0438 \u044f\u043f\u043e\u043d\u0441\u043a\u0430\u044f \u043e\u0442 <a href=\"http:\/\/labs.gree.jp\/Top\/OpenSource\/DBus-en.html\">GREE Labs<\/a>. \u041d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0443\u0441\u043f\u0435\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 Pecl D-Bus, \u044f\u043f\u043e\u043d\u0441\u043a\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u044b \u043d\u0435 \u0443\u0434\u043e\u0441\u0442\u043e\u0438\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u043e\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f. \u0421\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b C++ \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c QtDBus, \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 Qt.<\/li>\n<\/ol>\n<p>  <\/p>\n<h4>\u00ab\u041a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439\u00bb \u043a\u043e\u0434<\/h4>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u00ab\u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0433\u043e\u00bb PHP-\u043a\u043e\u0434\u0430. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0447\u0442\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 (\u043d\u0430\u0448 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 Qt), \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u043e D-Bus-\u0441\u0435\u0440\u0432\u0438\u0441 \u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u00abtest.service\u00bb. \u0421\u0435\u0440\u0432\u0438\u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 \u043d\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 &quot;\/&quot; (\u043f\u043e\u0434\u043e\u0431\u043d\u043e \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0432 Linux). \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 &quot;\/test&quot;. \u041e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u041e\u0431\u044a\u0435\u043a\u0442 &quot;\/test&quot; \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u00abtest.iface\u00bb \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u00absum\u00bb.<\/p>\n<p>  client.php:  <\/p>\n<pre><code class=\"php\">\/\/ \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u0448\u0438\u043d\u043e\u0439 D-Bus. $dbus = new DBus(DBus::BUS_SYSTEM);  \/\/ \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0434\u043b\u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432. $proxy = $dbus-&gt;createProxy(&quot;test.service&quot;, &quot;\/test&quot;, &quot;test.iface&quot;);  try { \t\/\/ \u041e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u043c \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \t$result = $proxy-&gt;sum(42, 13); \tvar_dump($result); } catch (Exception $e) { \tprint $e-&gt;getMessage().&quot;\\n&quot;; } <\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u0434\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u00absum\u00bb \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u00abtest.iface\u00bb \u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e \u043f\u0443\u0442\u0438 &quot;\/test&quot;, \u043d\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u00abtest.service\u00bb \u0447\u0435\u0440\u0435\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0443\u044e \u0448\u0438\u043d\u0443 D-Bus. \u041c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u0434\u0432\u0443\u043c\u044f \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u00abtest.service\u00bb \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435 42-\u0445 \u0438 13-\u0442\u0438, \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 var_dump.<\/p>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f D-Bus-\u043c\u043e\u0434\u0443\u043b\u044f<\/h4>\n<p>  \u041f\u0440\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043c\u043e\u0434\u0443\u043b\u044f, \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0438\u0445 \u0446\u0435\u043b\u044f\u0445 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u044e ZendFramework (\u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0430\u043d\u043e\u0439 \u043d\u0430 C++). \u042d\u0442\u043e \u0431\u044b\u043b\u043e \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043d\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u0438\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u044b \u043a\u0430\u043a \u00ab\u0441\u0435\u0440\u0432\u0438\u0441\u00bb, \u00ab\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u00bb, \u00ab\u043e\u0431\u044a\u0435\u043a\u0442\u00bb \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u0430\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a D-Bus. \u0418, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u044b, \u043c\u044b \u0432\u0437\u044f\u043b\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u00ab\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u00bb (Action) \u0438 \u00ab\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u00bb (Controller) \u0438\u0437 ZendFramework.<br \/>  \u041f\u043e\u0434 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043c <b>\u00ab\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u00bb<\/b> \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442 QThread \u043a\u043b\u0430\u0441\u0441, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0431\u043e\u0439 \u043d\u0438\u0442\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043b\u044e\u0431\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b.<br \/>  \u0410 <b>\u00ab\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c\u00bb<\/b> \u043d\u0430\u0437\u0432\u0430\u043b\u0438 \u043a\u043b\u0430\u0441\u0441, \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0437\u043e\u0432\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0432 \u0441\u0432\u043e\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043d\u0443\u0436\u043d\u043e \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043e\u0442 QObject \u0438 QDBusContext.<\/p>\n<h5>\u0413\u043e\u043b\u043e\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/h5>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u043a\u043e\u0434 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f (\u0444\u0430\u0439\u043b main.cpp). \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u0448\u0438\u043d\u0435 D-Bus.<\/p>\n<pre><code>#include &lt;QCoreApplication&gt; #include &lt;QDebug&gt; #include &lt;QDBusConnection&gt; #include &quot;TestController.h&quot;  #define SERVICE_NAME &quot;test.service&quot; #define OBJECT_PATH &quot;\/test&quot;  int main(int argc, char *argv[]) { \tQCoreApplication app(argc, argv); \t\/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u0448\u0438\u043d\u043e\u0439 D-Bus \tQDBusConnection conn = QDBusConnection::systemBus();  \t\/\/ \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \tif (! conn.registerService(SERVICE_NAME)) { \t\tqDebug() &lt;&lt; &quot;Error:&quot; &lt;&lt;  conn.lastError().message(); \t\texit(EXIT_FAILURE); \t}  \tTestController controller; \t\/\/ \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \tconn.registerObject(OBJECT_PATH, &controller, QDBusConnection::ExportAllContents);  \treturn app.exec(); } <\/code><\/pre>\n<h5>\u00ab\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u00bb<\/h5>\n<p>  \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0434\u043b\u044f \u043c\u0435\u0436\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043f\u043e D-Bus, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 sum, \u0432\u0442\u043e\u0440\u043e\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0436\u0434\u0430\u0442\u044c \u043f\u043e\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0435 \u043e\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0430, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0443\u0441\u043a \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u043d\u0438\u0442\u0438 (\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f) \u0438 \u0432\u044b\u0445\u043e\u0434 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 (\u0444\u0430\u0439\u043b TestController.h). \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435.<\/p>\n<pre><code>#ifndef TEST_CONTROLLER_H #define TEST_CONTROLLER_H  #include &lt;QObject&gt; #include &lt;QDBusContext&gt; #include &lt;QDBusConnection&gt; #include &lt;QDebug&gt; #include &quot;SumAction.h&quot;  class TestController: public QObject, protected QDBusContext { \tQ_OBJECT \tQ_CLASSINFO(&quot;D-Bus Interface&quot;, &quot;test.iface&quot;) \/\/ \u0418\u043c\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430  public: \tQ_INVOKABLE int sum(int a, int b) { \t\t\/\/ \u0421\u043e\u043e\u0431\u0449\u0430\u0435\u043c D-Bus, \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u0438\u0439\u0434\u0451\u0442 \u043f\u043e\u0437\u0436\u0435. \t\tsetDelayedReply(true); \t\t\/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0438\u0442\u044c \t\t(new SumAction(a, b, this))-&gt;start(); \t\t\/\/ \u0424\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430. \u0420\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0451\u043d \u0438\u0437 \u043d\u0438\u0442\u0438. \t\treturn 0; \t}; };  #endif \/\/ TEST_CONTROLLER_H <\/code><\/pre>\n<h5>\u00ab\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u00bb<\/h5>\n<p>  \u0412 <b>\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u0445<\/b> \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043c\u043e\u0434\u0443\u043b\u044f. \u041a\u0430\u0436\u0434\u043e\u043c\u0443 \u043c\u0435\u0442\u043e\u0434\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 Action, \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Action.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>#ifndef ACTION_H #define ACTION_H  #include &lt;QThread&gt; #include &lt;QDBusMessage&gt; #include &lt;QDBusArgument&gt; #include &lt;QTime&gt; #include &lt;QDBusReply&gt;  class QDBusContext;  class Action: public QThread { \tQ_OBJECT  public: \tAction(const QDBusContext* context); \tvirtual ~Action();  \t\/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043e\u0433\u043e \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435 \u0442\u0438\u043f\u0430 \ttemplate&lt;typename X&gt; \tQDBusReply&lt;X&gt; reply() const { return _reply; }  protected: \t\/\/ \u041d\u0435\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0435. \tinline QDBusMessage& reply() { return _reply; } \t\/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \tinline const QDBusMessage& request() { return _request; }  private slots: \tvoid onFinished();  private: \tQDBusConnection* _connection; \tQDBusMessage _request; \tQDBusMessage _reply; };  #endif \/\/ ACTION_H <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Action.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>#include &quot;Action.h&quot;  #include &lt;QDBusConnection&gt; #include &lt;QDBusContext&gt; #include &lt;QDebug&gt; #include &lt;QDir&gt;  Action::Action(const QDBusContext* context) { \tif (context != 0) { \t\t\/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043f\u0438\u044e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \t\t_connection = new QDBusConnection(context-&gt;connection()); \t\t_request = context-&gt;message(); \t} \telse { \t\t_connection = 0; \t\t_request = QDBusMessage(); \t}  \t\/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \t_reply = _request.createReply();  \t\/\/ \u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043d\u0438\u0442\u0438 \tif (! connect(this, SIGNAL(finished()), this, SLOT(onFinished()))) \t\tqFatal(&quot;SIGNAL\/SLOT connection error&quot;); }  Action::~Action() { \tif (_connection != 0) \t\tdelete _connection; }  void Action::onFinished() { \tif (_connection != 0) { \t\t\/\/ \u041e\u0442\u0441\u044b\u043b\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u043e D-Bus \t\t_connection-&gt;send(_reply); \t}  \t\/* \t * \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u043d\u0438\u0442\u044c \u0431\u044b\u043b\u0430 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 \u0438\u0437 \t * \u043d\u0438\u0442\u0438, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0439\u0441\u044f \u0432 \u0446\u0438\u043a\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 (event loop). \t *\/ \tdeleteLater(); } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0423\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0432 \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u0441\u044f \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u043d\u0435 \u0437\u0430\u0431\u043e\u0442\u044f\u0441\u044c \u043e \u0434\u0435\u0442\u0430\u043b\u044f\u0445 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 D-Bus. \u0412\u0441\u0451, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0430, \u0441\u043b\u043e\u0436\u0438\u0442\u044c a \u0438 b, \u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 reply().<\/p>\n<p>  SumAction.h:  <\/p>\n<pre><code>#ifndef SUMACTION_H #define SUMACTION_H  #include &quot;Action.h&quot;  class SumAction: public Action { \tQ_OBJECT public: \tSumAction(int a, int b, const QDBusContext* context): \t\tAction(context), \t\t_a(a), \t\t_b(b) \t{} \tvirtual ~SumAction() {}; protected: \tvoid run() { \t\treply() &lt;&lt; _a + _b; \t} private: \tint _a; \tint _b; };  #endif \/\/ SUMACTION_H <\/code><\/pre>\n<p>  <\/p>\n<h4>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f D-Bus<\/h4>\n<p>  \u041e\u0442\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043c\u043e\u0434\u0443\u043b\u044c, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0435\u0435 D-Bus-\u0441\u0435\u0440\u0432\u0438\u0441 \u00abtest.service\u00bb. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c:<\/p>\n<pre><code class=\"bash\">$ .\/dbus-test Error: &quot;Connection &quot;:1.66&quot; is not allowed to own the service &quot;test.service&quot; due to security policies in the configuration file&quot; <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e D-Bus. D-Bus \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0433\u0438\u0431\u043a\u043e\u0439 <a href=\"http:\/\/dbus.freedesktop.org\/doc\/dbus-daemon.1.html\">\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438<\/a> \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b: \/etc\/dbus-1\/system.d\/dbus-test.conf \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"xml\">&lt;!DOCTYPE busconfig PUBLIC  &quot;-\/\/freedesktop\/\/DTD D-BUS Bus Configuration 1.0\/\/EN&quot;  &quot;http:\/\/www.freedesktop.org\/standards\/dbus\/1.0\/busconfig.dtd&quot;&gt; &lt;busconfig&gt;    &lt;policy context=&quot;default&quot;&gt;     &lt;allow own=&quot;test.service&quot;\/&gt;     &lt;allow send_destination=&quot;test.service&quot;\/&gt;     &lt;allow receive_sender=&quot;test.service&quot;\/&gt;   &lt;\/policy&gt; &lt;\/busconfig&gt; <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0434\u0435\u043c\u043e\u043d D-Bus \u2014 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0442\u0443\u043f\u044f\u0442 \u0432 \u0441\u0438\u043b\u0443 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430.<br \/>  \u041f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u0437\u0430\u043f\u0443\u0441\u043a \u043c\u043e\u0434\u0443\u043b\u044f \u0438, \u0435\u0441\u043b\u0438 \u043e\u043d \u0431\u043b\u0430\u0433\u043e\u043f\u043e\u043b\u0443\u0447\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0441\u044f, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043a \u043d\u0435\u043c\u0443 \u0438\u0437 PHP-\u0441\u043a\u0440\u0438\u043f\u0442\u0430.<\/p>\n<pre><code class=\"bash\">$ php client.php int(55) <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: 42 + 13 = 55. \u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c <a href=\"https:\/\/www.assembla.com\/code\/dbus-test\/subversion\/nodes\/trunk\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u0441\u043f\u043e\u0441\u043e\u0431 \u043c\u0435\u0436\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043d\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u043d\u0430\u043c \u043d\u0430\u043b\u0430\u0434\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430 C++, \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438, \u043d\u0443\u0436\u0434\u0430\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u0432 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0421++ (\u0438 Qt \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438), \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043d\u0430 PHP. \t\t\t \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/165959\/\"> http:\/\/habrahabr.ru\/post\/165959\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043c\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0449\u0435\u0439, \u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0443\u044f\u0441\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u043c <a href=\"http:\/\/habrahabr.ru\/post\/144611\/\">DRY<\/a> (Don&#8217;t Repeat Yourself \u2014 \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0439\u0441\u044f), \u043f\u0440\u0438\u043d\u044f\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043e\u0431\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c.<\/p>\n<p>  \u041a \u043c\u043e\u0434\u0443\u043b\u044e \u0431\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f:  <\/p>\n<ul>\n<li>\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432;<\/li>\n<li>\u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u00ab\u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0433\u043e\u00bb \u043a\u043e\u0434\u0430;<\/li>\n<li>\u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b.<\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-165959","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/165959","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=165959"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/165959\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=165959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=165959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=165959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}