1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains code that communicates with ladishd through D-Bus
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <dbus/dbus.h>
32 #include "lash_proxy.hpp"
33 #include "session.hpp"
34 #include "project.hpp"
35 #include "lash_client.hpp"
36 #include "globals.hpp"
37 #include "dbus_helpers.h"
39 #define LASH_SERVICE DBUS_NAME_BASE
40 #define LASH_OBJECT "/"
41 #define LASH_IFACE_CONTROL DBUS_NAME_BASE ".Control"
43 struct lash_proxy_impl
47 void fetch_loaded_projects();
48 void fetch_project_clients(boost::shared_ptr
<project
> project_ptr
);
50 static void error_msg(const std::string
& msg
);
51 static void info_msg(const std::string
& msg
);
56 DBusConnection
* connection
,
57 DBusMessage
* message
,
62 bool response_expected
,
65 DBusMessage
** reply_ptr_ptr
,
69 boost::shared_ptr
<project
>
73 boost::shared_ptr
<lash_client
>
75 boost::shared_ptr
<project
> project_ptr
,
81 bool _server_responding
;
82 session
* _session_ptr
;
83 lash_proxy
* _interface_ptr
;
86 lash_proxy::lash_proxy(session
* session_ptr
)
88 _impl_ptr
= new lash_proxy_impl
;
89 _impl_ptr
->_interface_ptr
= this;
90 _impl_ptr
->_session_ptr
= session_ptr
;
94 lash_proxy::~lash_proxy()
100 lash_proxy_impl::init()
102 _server_responding
= false;
104 patchage_dbus_add_match("type='signal',interface='" DBUS_INTERFACE_DBUS
"',member=NameOwnerChanged,arg0='" LASH_SERVICE
"'");
105 patchage_dbus_add_match("type='signal',interface='" LASH_IFACE_CONTROL
"',member=StudioAppeared");
106 patchage_dbus_add_match("type='signal',interface='" LASH_IFACE_CONTROL
"',member=StudioDisappeared");
107 patchage_dbus_add_match("type='signal',interface='" LASH_IFACE_CONTROL
"',member=ProjectAppeared");
108 patchage_dbus_add_match("type='signal',interface='" LASH_IFACE_CONTROL
"',member=ProjectDisappeared");
109 patchage_dbus_add_match("type='signal',interface='" LASH_IFACE_CONTROL
"',member=ProjectNameChanged");
110 patchage_dbus_add_match("type='signal',interface='" LASH_IFACE_CONTROL
"',member=ProjectModifiedStatusChanged");
111 patchage_dbus_add_match("type='signal',interface='" LASH_IFACE_CONTROL
"',member=ProjectDescriptionChanged");
112 patchage_dbus_add_match("type='signal',interface='" LASH_IFACE_CONTROL
"',member=ProjectNotesChanged");
113 patchage_dbus_add_match("type='signal',interface='" LASH_IFACE_CONTROL
"',member=ClientAppeared");
114 patchage_dbus_add_match("type='signal',interface='" LASH_IFACE_CONTROL
"',member=ClientDisappeared");
115 patchage_dbus_add_match("type='signal',interface='" LASH_IFACE_CONTROL
"',member=ClientNameChanged");
117 patchage_dbus_add_filter(dbus_message_hook
, this);
119 // get initial list of projects
120 // calling any method to updates server responding status
121 // this also actiavtes lash object if it not activated already
122 //fetch_loaded_projects();
124 g_app
->set_studio_availability(false);
128 lash_proxy::is_active()
130 return _impl_ptr
->_server_responding
;
134 lash_proxy::try_activate()
136 std::list
<lash_project_info
> projects
;
137 get_available_projects(projects
);
141 lash_proxy::deactivate()
147 lash_proxy_impl::error_msg(const std::string
& msg
)
149 g_app
->error_msg((std::string
)"[LASH] " + msg
);
153 lash_proxy_impl::info_msg(const std::string
& msg
)
155 g_app
->info_msg((std::string
)"[LASH] " + msg
);
159 lash_proxy_impl::dbus_message_hook(
160 DBusConnection
* connection
,
161 DBusMessage
* message
,
164 const char * project_name
;
165 const char * new_project_name
;
166 const char * object_name
;
167 const char * old_owner
;
168 const char * new_owner
;
169 const char * value_string
;
170 const char * client_id
;
171 const char * client_name
;
172 dbus_bool_t modified_status
;
173 boost::shared_ptr
<project
> project_ptr
;
174 boost::shared_ptr
<lash_client
> client_ptr
;
177 lash_proxy_impl
* me
= reinterpret_cast<lash_proxy_impl
*>(proxy
);
179 //info_msg("dbus_message_hook() called.");
181 // Handle signals we have subscribed for in attach()
183 if (dbus_message_is_signal(message
, DBUS_INTERFACE_DBUS
, "NameOwnerChanged"))
185 if (!dbus_message_get_args(
186 message
, &g_dbus_error
,
187 DBUS_TYPE_STRING
, &object_name
,
188 DBUS_TYPE_STRING
, &old_owner
,
189 DBUS_TYPE_STRING
, &new_owner
,
192 error_msg(str(boost::format("dbus_message_get_args() failed to extract NameOwnerChanged signal arguments (%s)") % g_dbus_error
.message
));
193 dbus_error_free(&g_dbus_error
);
194 return DBUS_HANDLER_RESULT_HANDLED
;
197 if ((std::string
)object_name
!= LASH_SERVICE
)
199 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED
;
202 if (old_owner
[0] == '\0')
204 info_msg((std::string
)"LASH activated.");
206 else if (new_owner
[0] == '\0')
208 info_msg((std::string
)"LASH deactivated.");
209 g_app
->set_studio_availability(false);
210 me
->_server_responding
= false;
213 return DBUS_HANDLER_RESULT_HANDLED
;
216 if (dbus_message_is_signal(message
, LASH_IFACE_CONTROL
, "StudioAppeared"))
218 info_msg((std::string
)"Studio appeared.");
219 g_app
->set_studio_availability(true);
221 return DBUS_HANDLER_RESULT_HANDLED
;
224 if (dbus_message_is_signal(message
, LASH_IFACE_CONTROL
, "StudioDisappeared"))
226 info_msg((std::string
)"Studio disappeared.");
227 g_app
->set_studio_availability(false);
229 return DBUS_HANDLER_RESULT_HANDLED
;
232 if (dbus_message_is_signal(message
, LASH_IFACE_CONTROL
, "ProjectAppeared"))
234 if (!dbus_message_get_args( message
, &g_dbus_error
,
235 DBUS_TYPE_STRING
, &project_name
,
238 error_msg(str(boost::format("dbus_message_get_args() failed to extract ProjectAppeared signal arguments (%s)") % g_dbus_error
.message
));
239 dbus_error_free(&g_dbus_error
);
240 return DBUS_HANDLER_RESULT_HANDLED
;
243 info_msg((std::string
)"Project '" + project_name
+ "' appeared.");
244 me
->on_project_added(project_name
);
246 return DBUS_HANDLER_RESULT_HANDLED
;
249 if (dbus_message_is_signal(message
, LASH_IFACE_CONTROL
, "ProjectDisappeared"))
251 if (!dbus_message_get_args(
252 message
, &g_dbus_error
,
253 DBUS_TYPE_STRING
, &project_name
,
256 error_msg(str(boost::format("dbus_message_get_args() failed to extract ProjectDisappeared signal arguments (%s)") % g_dbus_error
.message
));
257 dbus_error_free(&g_dbus_error
);
258 return DBUS_HANDLER_RESULT_HANDLED
;
261 info_msg((std::string
)"Project '" + project_name
+ "' disappeared.");
262 me
->_session_ptr
->project_close(project_name
);
264 return DBUS_HANDLER_RESULT_HANDLED
;
268 if (dbus_message_is_signal(message
, LASH_IFACE_CONTROL
, "ProjectNameChanged"))
270 if (!dbus_message_get_args(
271 message
, &g_dbus_error
,
272 DBUS_TYPE_STRING
, &project_name
,
273 DBUS_TYPE_STRING
, &new_project_name
,
276 error_msg(str(boost::format("dbus_message_get_args() failed to extract ProjectNameChanged signal arguments (%s)") % g_dbus_error
.message
));
277 dbus_error_free(&g_dbus_error
);
278 return DBUS_HANDLER_RESULT_HANDLED
;
281 info_msg((std::string
)"Project '" + project_name
+ "' renamed to '" + new_project_name
+ "'.");
283 project_ptr
= me
->_session_ptr
->find_project_by_name(project_name
);
286 project_ptr
->on_name_changed(new_project_name
);
289 return DBUS_HANDLER_RESULT_HANDLED
;
292 if (dbus_message_is_signal(message
, LASH_IFACE_CONTROL
, "ProjectModifiedStatusChanged"))
294 if (!dbus_message_get_args(
295 message
, &g_dbus_error
,
296 DBUS_TYPE_STRING
, &project_name
,
297 DBUS_TYPE_BOOLEAN
, &modified_status
,
300 error_msg(str(boost::format("dbus_message_get_args() failed to extract ProjectModifiedStatusChanged signal arguments (%s)") % g_dbus_error
.message
));
301 dbus_error_free(&g_dbus_error
);
302 return DBUS_HANDLER_RESULT_HANDLED
;
305 info_msg((std::string
)"Project '" + project_name
+ "' modified status changed to '" + (modified_status
? "true" : "false") + "'.");
307 project_ptr
= me
->_session_ptr
->find_project_by_name(project_name
);
310 project_ptr
->on_modified_status_changed(modified_status
);
313 return DBUS_HANDLER_RESULT_HANDLED
;
316 if (dbus_message_is_signal(message
, LASH_IFACE_CONTROL
, "ProjectDescriptionChanged"))
318 if (!dbus_message_get_args(
319 message
, &g_dbus_error
,
320 DBUS_TYPE_STRING
, &project_name
,
321 DBUS_TYPE_STRING
, &value_string
,
324 error_msg(str(boost::format("dbus_message_get_args() failed to extract ProjectDescriptionChanged signal arguments (%s)") % g_dbus_error
.message
));
325 dbus_error_free(&g_dbus_error
);
326 return DBUS_HANDLER_RESULT_HANDLED
;
329 info_msg((std::string
)"Project '" + project_name
+ "' description changed.");
331 project_ptr
= me
->_session_ptr
->find_project_by_name(project_name
);
334 project_ptr
->on_description_changed(value_string
);
337 return DBUS_HANDLER_RESULT_HANDLED
;
340 if (dbus_message_is_signal(message
, LASH_IFACE_CONTROL
, "ProjectNotesChanged"))
342 if (!dbus_message_get_args(
343 message
, &g_dbus_error
,
344 DBUS_TYPE_STRING
, &project_name
,
345 DBUS_TYPE_STRING
, &value_string
,
348 error_msg(str(boost::format("dbus_message_get_args() failed to extract ProjectNotesChanged signal arguments (%s)") % g_dbus_error
.message
));
349 dbus_error_free(&g_dbus_error
);
350 return DBUS_HANDLER_RESULT_HANDLED
;
353 info_msg((std::string
)"Project '" + project_name
+ "' notes changed.");
355 project_ptr
= me
->_session_ptr
->find_project_by_name(project_name
);
358 project_ptr
->on_notes_changed(value_string
);
361 return DBUS_HANDLER_RESULT_HANDLED
;
364 if (dbus_message_is_signal(message
, LASH_IFACE_CONTROL
, "ClientAppeared"))
366 if (!dbus_message_get_args(
367 message
, &g_dbus_error
,
368 DBUS_TYPE_STRING
, &client_id
,
369 DBUS_TYPE_STRING
, &project_name
,
370 DBUS_TYPE_STRING
, &client_name
,
373 error_msg(str(boost::format("dbus_message_get_args() failed to extract ClientAppeared signal arguments (%s)") % g_dbus_error
.message
));
374 dbus_error_free(&g_dbus_error
);
375 return DBUS_HANDLER_RESULT_HANDLED
;
378 info_msg((std::string
)"Client '" + client_id
+ "':'" + client_name
+ "' appeared in project '" + project_name
+ "'.");
380 project_ptr
= me
->_session_ptr
->find_project_by_name(project_name
);
383 me
->on_client_added(project_ptr
, client_id
, client_name
);
386 return DBUS_HANDLER_RESULT_HANDLED
;
389 if (dbus_message_is_signal(message
, LASH_IFACE_CONTROL
, "ClientDisappeared"))
391 if (!dbus_message_get_args(
392 message
, &g_dbus_error
,
393 DBUS_TYPE_STRING
, &client_id
,
394 DBUS_TYPE_STRING
, &project_name
,
397 error_msg(str(boost::format("dbus_message_get_args() failed to extract ClientDisappeared signal arguments (%s)") % g_dbus_error
.message
));
398 dbus_error_free(&g_dbus_error
);
399 return DBUS_HANDLER_RESULT_HANDLED
;
402 info_msg((std::string
)"Client '" + client_id
+ "' of project '" + project_name
+ "' disappeared.");
404 client_ptr
= me
->_session_ptr
->find_client_by_id(client_id
);
407 client_ptr
->get_project()->on_client_removed(client_id
);
408 me
->_session_ptr
->client_remove(client_id
);
411 return DBUS_HANDLER_RESULT_HANDLED
;
414 if (dbus_message_is_signal(message
, LASH_IFACE_CONTROL
, "ClientNameChanged"))
416 if (!dbus_message_get_args(
417 message
, &g_dbus_error
,
418 DBUS_TYPE_STRING
, &client_id
,
419 DBUS_TYPE_STRING
, &client_name
,
422 error_msg(str(boost::format("dbus_message_get_args() failed to extract ClientNameChanged signal arguments (%s)") % g_dbus_error
.message
));
423 dbus_error_free(&g_dbus_error
);
424 return DBUS_HANDLER_RESULT_HANDLED
;
427 info_msg((std::string
)"Client '" + client_id
+ "' name changed to '" + client_name
+ "'.");
429 client_ptr
= me
->_session_ptr
->find_client_by_id(client_id
);
432 client_ptr
->on_name_changed(client_name
);
435 return DBUS_HANDLER_RESULT_HANDLED
;
438 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED
;
442 lash_proxy_impl::call(
443 bool response_expected
,
446 DBusMessage
** reply_ptr_ptr
,
452 va_start(ap
, in_type
);
454 _server_responding
= patchage_dbus_call_valist(
466 return _server_responding
;
470 lash_proxy_impl::fetch_loaded_projects()
472 DBusMessage
* reply_ptr
;
473 const char * reply_signature
;
474 DBusMessageIter iter
;
475 DBusMessageIter array_iter
;
476 const char * project_name
;
477 boost::shared_ptr
<project
> project_ptr
;
479 if (!call(true, LASH_IFACE_CONTROL
, "ProjectsGet", &reply_ptr
, DBUS_TYPE_INVALID
)) {
483 reply_signature
= dbus_message_get_signature(reply_ptr
);
485 if (strcmp(reply_signature
, "as") != 0)
487 error_msg((std::string
)"ProjectsGet() reply signature mismatch. " + reply_signature
);
491 dbus_message_iter_init(reply_ptr
, &iter
);
493 for (dbus_message_iter_recurse(&iter
, &array_iter
);
494 dbus_message_iter_get_arg_type(&array_iter
) != DBUS_TYPE_INVALID
;
495 dbus_message_iter_next(&array_iter
))
497 dbus_message_iter_get_basic(&array_iter
, &project_name
);
498 project_ptr
= on_project_added(project_name
);
499 fetch_project_clients(project_ptr
);
503 dbus_message_unref(reply_ptr
);
507 lash_proxy_impl::fetch_project_clients(
508 boost::shared_ptr
<project
> project_ptr
)
510 DBusMessage
* reply_ptr
;
511 const char * reply_signature
;
512 DBusMessageIter iter
;
513 DBusMessageIter array_iter
;
514 DBusMessageIter struct_iter
;
515 const char * client_id
;
516 const char * client_name
;
517 std::string project_name
;
518 const char * project_name_cstr
;
520 project_ptr
->get_name(project_name
);
521 project_name_cstr
= project_name
.c_str();
528 DBUS_TYPE_STRING
, &project_name_cstr
,
534 reply_signature
= dbus_message_get_signature(reply_ptr
);
536 if (strcmp(reply_signature
, "a(ss)") != 0)
538 error_msg((std::string
)"ProjectGetClients() reply signature mismatch. " + reply_signature
);
542 dbus_message_iter_init(reply_ptr
, &iter
);
544 for (dbus_message_iter_recurse(&iter
, &array_iter
);
545 dbus_message_iter_get_arg_type(&array_iter
) != DBUS_TYPE_INVALID
;
546 dbus_message_iter_next(&array_iter
))
548 dbus_message_iter_recurse(&array_iter
, &struct_iter
);
550 dbus_message_iter_get_basic(&struct_iter
, &client_id
);
551 dbus_message_iter_next(&struct_iter
);
552 dbus_message_iter_get_basic(&struct_iter
, &client_name
);
553 dbus_message_iter_next(&struct_iter
);
555 on_client_added(project_ptr
, client_id
, client_name
);
559 dbus_message_unref(reply_ptr
);
562 boost::shared_ptr
<project
>
563 lash_proxy_impl::on_project_added(
566 boost::shared_ptr
<project
> project_ptr(new project(_interface_ptr
, name
));
568 _session_ptr
->project_add(project_ptr
);
573 boost::shared_ptr
<lash_client
>
574 lash_proxy_impl::on_client_added(
575 boost::shared_ptr
<project
> project_ptr
,
579 boost::shared_ptr
<lash_client
> client_ptr(
586 project_ptr
->on_client_added(client_ptr
);
587 _session_ptr
->client_add(client_ptr
);
593 lash_proxy::get_available_projects(
594 std::list
<lash_project_info
>& projects
)
596 DBusMessage
* reply_ptr
;
597 const char * reply_signature
;
598 DBusMessageIter iter
;
599 DBusMessageIter array_iter
;
600 DBusMessageIter struct_iter
;
601 DBusMessageIter dict_iter
;
602 DBusMessageIter dict_entry_iter
;
603 DBusMessageIter variant_iter
;
604 const char * project_name
;
606 const char * value_type
;
607 dbus_uint32_t value_uint32
;
608 const char * value_string
;
609 lash_project_info project_info
;
611 if (!_impl_ptr
->call(true, LASH_IFACE_CONTROL
, "ProjectsGetAvailable", &reply_ptr
, DBUS_TYPE_INVALID
))
616 reply_signature
= dbus_message_get_signature(reply_ptr
);
618 if (strcmp(reply_signature
, "a(sa{sv})") != 0)
620 lash_proxy_impl::error_msg((std::string
)"ProjectsGetAvailable() reply signature mismatch. " + reply_signature
);
624 dbus_message_iter_init(reply_ptr
, &iter
);
626 for (dbus_message_iter_recurse(&iter
, &array_iter
);
627 dbus_message_iter_get_arg_type(&array_iter
) != DBUS_TYPE_INVALID
;
628 dbus_message_iter_next(&array_iter
))
630 dbus_message_iter_recurse(&array_iter
, &struct_iter
);
632 dbus_message_iter_get_basic(&struct_iter
, &project_name
);
634 project_info
.name
= project_name
;
635 project_info
.modification_time
= 0;
636 project_info
.description
.erase();
638 dbus_message_iter_next(&struct_iter
);
640 for (dbus_message_iter_recurse(&struct_iter
, &dict_iter
);
641 dbus_message_iter_get_arg_type(&dict_iter
) != DBUS_TYPE_INVALID
;
642 dbus_message_iter_next(&dict_iter
))
644 dbus_message_iter_recurse(&dict_iter
, &dict_entry_iter
);
645 dbus_message_iter_get_basic(&dict_entry_iter
, &key
);
646 dbus_message_iter_next(&dict_entry_iter
);
647 dbus_message_iter_recurse(&dict_entry_iter
, &variant_iter
);
648 value_type
= dbus_message_iter_get_signature(&variant_iter
);
649 if (value_type
[0] != 0 && value_type
[1] == 0)
653 case DBUS_TYPE_UINT32
:
654 if (strcmp(key
, "Modification Time") == 0)
656 dbus_message_iter_get_basic(&variant_iter
, &value_uint32
);
657 project_info
.modification_time
= value_uint32
;
660 case DBUS_TYPE_STRING
:
661 if (strcmp(key
, "Description") == 0)
663 dbus_message_iter_get_basic(&variant_iter
, &value_string
);
664 project_info
.description
= value_string
;
671 projects
.push_back(project_info
);
675 dbus_message_unref(reply_ptr
);
679 lash_proxy::load_project(
680 const std::string
& project_name
)
682 DBusMessage
* reply_ptr
;
683 const char * project_name_cstr
;
685 project_name_cstr
= project_name
.c_str();
687 if (!_impl_ptr
->call(true, LASH_IFACE_CONTROL
, "ProjectOpen", &reply_ptr
, DBUS_TYPE_STRING
, &project_name_cstr
, DBUS_TYPE_INVALID
))
692 dbus_message_unref(reply_ptr
);
696 lash_proxy::save_all_projects()
698 DBusMessage
* reply_ptr
;
700 if (!_impl_ptr
->call(true, LASH_IFACE_CONTROL
, "ProjectsSaveAll", &reply_ptr
, DBUS_TYPE_INVALID
))
705 dbus_message_unref(reply_ptr
);
709 lash_proxy::save_project(
710 const std::string
& project_name
)
712 DBusMessage
* reply_ptr
;
713 const char * project_name_cstr
;
715 project_name_cstr
= project_name
.c_str();
717 if (!_impl_ptr
->call(true, LASH_IFACE_CONTROL
, "ProjectSave", &reply_ptr
, DBUS_TYPE_STRING
, &project_name_cstr
, DBUS_TYPE_INVALID
))
722 dbus_message_unref(reply_ptr
);
726 lash_proxy::close_project(
727 const std::string
& project_name
)
729 DBusMessage
* reply_ptr
;
730 const char * project_name_cstr
;
732 project_name_cstr
= project_name
.c_str();
734 if (!_impl_ptr
->call(true, LASH_IFACE_CONTROL
, "ProjectClose", &reply_ptr
, DBUS_TYPE_STRING
, &project_name_cstr
, DBUS_TYPE_INVALID
))
739 dbus_message_unref(reply_ptr
);
743 lash_proxy::close_all_projects()
745 DBusMessage
* reply_ptr
;
747 if (!_impl_ptr
->call(true, LASH_IFACE_CONTROL
, "ProjectsCloseAll", &reply_ptr
, DBUS_TYPE_INVALID
))
752 dbus_message_unref(reply_ptr
);
756 lash_proxy::project_rename(
757 const std::string
& old_name
,
758 const std::string
& new_name
)
760 DBusMessage
* reply_ptr
;
761 const char * old_name_cstr
;
762 const char * new_name_cstr
;
764 old_name_cstr
= old_name
.c_str();
765 new_name_cstr
= new_name
.c_str();
767 if (!_impl_ptr
->call(
772 DBUS_TYPE_STRING
, &old_name_cstr
,
773 DBUS_TYPE_STRING
, &new_name_cstr
,
779 dbus_message_unref(reply_ptr
);
783 lash_proxy::get_loaded_project_properties(
784 const std::string
& name
,
785 lash_loaded_project_properties
& properties
)
787 DBusMessage
* reply_ptr
;
788 const char * reply_signature
;
789 DBusMessageIter iter
;
790 DBusMessageIter dict_iter
;
791 DBusMessageIter dict_entry_iter
;
792 DBusMessageIter variant_iter
;
794 const char * value_type
;
795 dbus_bool_t value_bool
;
796 const char * value_string
;
797 const char * project_name_cstr
;
799 project_name_cstr
= name
.c_str();
801 if (!_impl_ptr
->call(
804 "ProjectGetProperties",
806 DBUS_TYPE_STRING
, &project_name_cstr
,
812 reply_signature
= dbus_message_get_signature(reply_ptr
);
814 if (strcmp(reply_signature
, "a{sv}") != 0)
816 lash_proxy_impl::error_msg((std::string
)"ProjectGetProperties() reply signature mismatch. " + reply_signature
);
820 dbus_message_iter_init(reply_ptr
, &iter
);
822 for (dbus_message_iter_recurse(&iter
, &dict_iter
);
823 dbus_message_iter_get_arg_type(&dict_iter
) != DBUS_TYPE_INVALID
;
824 dbus_message_iter_next(&dict_iter
))
826 dbus_message_iter_recurse(&dict_iter
, &dict_entry_iter
);
827 dbus_message_iter_get_basic(&dict_entry_iter
, &key
);
828 dbus_message_iter_next(&dict_entry_iter
);
829 dbus_message_iter_recurse(&dict_entry_iter
, &variant_iter
);
830 value_type
= dbus_message_iter_get_signature(&variant_iter
);
831 if (value_type
[0] != 0 && value_type
[1] == 0)
835 case DBUS_TYPE_BOOLEAN
:
836 if (strcmp(key
, "Modified Status") == 0)
838 dbus_message_iter_get_basic(&variant_iter
, &value_bool
);
839 properties
.modified_status
= value_bool
;
842 case DBUS_TYPE_STRING
:
843 if (strcmp(key
, "Description") == 0)
845 dbus_message_iter_get_basic(&variant_iter
, &value_string
);
846 properties
.description
= value_string
;
848 else if (strcmp(key
, "Notes") == 0)
850 dbus_message_iter_get_basic(&variant_iter
, &value_string
);
851 properties
.notes
= value_string
;
859 dbus_message_unref(reply_ptr
);
863 lash_proxy::project_set_description(
864 const std::string
& project_name
,
865 const std::string
& description
)
867 DBusMessage
* reply_ptr
;
868 const char * project_name_cstr
;
869 const char * description_cstr
;
871 project_name_cstr
= project_name
.c_str();
872 description_cstr
= description
.c_str();
874 if (!_impl_ptr
->call(
877 "ProjectSetDescription",
879 DBUS_TYPE_STRING
, &project_name_cstr
,
880 DBUS_TYPE_STRING
, &description_cstr
,
886 dbus_message_unref(reply_ptr
);
890 lash_proxy::project_set_notes(
891 const std::string
& project_name
,
892 const std::string
& notes
)
894 DBusMessage
* reply_ptr
;
895 const char * project_name_cstr
;
896 const char * notes_cstr
;
898 project_name_cstr
= project_name
.c_str();
899 notes_cstr
= notes
.c_str();
901 if (!_impl_ptr
->call(
906 DBUS_TYPE_STRING
, &project_name_cstr
,
907 DBUS_TYPE_STRING
, ¬es_cstr
,
913 dbus_message_unref(reply_ptr
);
917 lash_proxy_impl::exit()
919 DBusMessage
* reply_ptr
;
931 dbus_message_unref(reply_ptr
);