39 #include <nsComponentManagerUtils.h>
40 #include <nsStringAPI.h>
41 #include <nsIMutableArray.h>
42 #include <nsISupportsPrimitives.h>
53 static PRLogModuleInfo* gDBusConnectionLog = nsnull;
54 #define LOG(args) PR_LOG(gDBusConnectionLog, PR_LOG_WARN, args)
70 if(!gDBusConnectionLog)
71 gDBusConnectionLog = PR_NewLogModule(
"ngDBusConnection");
77 NS_IF_RELEASE(mHandler);
80 NS_IMETHODIMP ngDBusConnection::Observe(
nsISupports* aSubject,
const char* aTopic,
const PRUnichar*
aData)
85 NS_ENSURE_SUCCESS(rv, rv);
93 NS_ENSURE_ARG_POINTER(aName);
96 LOG((
"Initializing DBus"));
99 NS_ENSURE_SUCCESS(rv, rv);
104 dbus_bus_request_name(mConn->get(),
aName, 0, &error);
109 dbus_connection_flush(mConn->get());
111 LOG((
"Setting up Timer"));
113 mTimer = do_CreateInstance(
"@mozilla.org/timer;1", &rv);
114 NS_ENSURE_SUCCESS(rv, rv);
115 rv = mTimer->Init(
this, 100, nsITimer::TYPE_REPEATING_SLACK);
116 NS_ENSURE_SUCCESS(rv, rv);
124 NS_IMETHODIMP ngDBusConnection::SetMatch(
const char *
match)
126 NS_ENSURE_ARG_POINTER(match);
129 LOG((
"Setting match %s", match));
132 dbus_bus_add_match (mConn->get(),
match, &error);
136 dbus_connection_flush(mConn->get());
138 LOG((
"DBus Connection Init"));
144 NS_IMETHODIMP ngDBusConnection::Check()
146 NS_ENSURE_TRUE(mConn,
NS_OK);
152 DBusMessageIter *reply_iter;
155 dbus_connection_read_write(mConn->get(), 0);
156 msg = dbus_connection_pop_message(mConn->get());
159 if(dbus_message_get_type(msg) == DBUS_MESSAGE_TYPE_METHOD_CALL || dbus_message_get_type(msg) == DBUS_MESSAGE_TYPE_SIGNAL){
160 LOG((
"*****Calling %s", dbus_message_get_member(msg)));
162 reply_iter = (DBusMessageIter*)NS_Alloc(
sizeof(DBusMessageIter));
164 dbus_message_iter_init(msg, &incoming_args);
166 reply = dbus_message_new_method_return(msg);
167 dbus_message_iter_init_append(reply, reply_iter);
169 outgoing_args.push_back(reply_iter);
172 const char*
interface = dbus_message_get_interface(msg);
173 const char*
path = dbus_message_get_path(msg);
174 const char* member = dbus_message_get_member(msg);
177 if(interface != nsnull)
LOG((
"Interface: %s", interface));
179 if(member != nsnull)
LOG((
"Member: %s", member));
182 NS_ENSURE_TRUE(mHandler, NS_ERROR_FAILURE);
184 rv = mHandler->HandleMethod(interface,
path, member);
185 NS_ENSURE_SUCCESS(rv, rv);
187 LOG((
"Just after Handler call"));
189 dbus_uint32_t serial = 0;
192 NS_ENSURE_TRUE(dbus_connection_send(mConn->get(), reply, &serial), NS_ERROR_OUT_OF_MEMORY);
194 while(!outgoing_args.empty()){
195 NS_Free(outgoing_args.back());
196 outgoing_args.pop_back();
199 dbus_connection_flush(mConn->get());
200 dbus_message_unref(reply);
203 LOG((
"Done Handler call"));
206 dbus_message_unref(msg);
214 NS_IMETHODIMP ngDBusConnection::End(PRInt32 *_retval)
221 NS_IMETHODIMP ngDBusConnection::PrepareMethodCall(
const char* dest,
const char*
path,
const char* inter,
const char*
name)
223 NS_ENSURE_ARG_POINTER(dest);
224 NS_ENSURE_ARG_POINTER(path);
225 NS_ENSURE_ARG_POINTER(inter);
226 NS_ENSURE_ARG_POINTER(name);
228 LOG((
"*****Preparing method call %s, %s, %s", path, inter, name));
229 DBusMessageIter* reply_iter = (DBusMessageIter*)NS_Alloc(
sizeof(DBusMessageIter));
232 signal_msg = dbus_message_new_method_call(dest,
236 dbus_message_iter_init_append(signal_msg, reply_iter);
237 outgoing_args.push_back(reply_iter);
243 NS_IMETHODIMP ngDBusConnection::SendMethodCall()
245 LOG((
"Starting to send method call"));
247 dbus_connection_send(mConn->get(), signal_msg, NULL);
249 dbus_message_unref(signal_msg);
251 LOG((
"Freeing args"));
252 while(!outgoing_args.empty()){
253 NS_Free(outgoing_args.back());
254 outgoing_args.pop_back();
257 dbus_connection_flush(mConn->get());
259 LOG((
"*****Method Call Sent"));
265 NS_IMETHODIMP ngDBusConnection::PrepareSignal(
const char *path,
const char *inter,
const char *name)
267 NS_ENSURE_ARG_POINTER(path);
268 NS_ENSURE_ARG_POINTER(inter);
269 NS_ENSURE_ARG_POINTER(name);
271 LOG((
"*****Preparing signal %s, %s, %s", path, inter, name));
272 signal_msg = dbus_message_new_signal(path, inter, name);
274 DBusMessageIter* reply_iter = (DBusMessageIter*)NS_Alloc(
sizeof(DBusMessageIter));
276 dbus_message_iter_init_append(signal_msg, reply_iter);
277 outgoing_args.push_back(reply_iter);
279 LOG((
"Signal prepared"));
285 NS_IMETHODIMP ngDBusConnection::SendSignal()
287 LOG((
"Starting to send signal"));
289 dbus_connection_send(mConn->get(), signal_msg, NULL);
291 dbus_message_unref(signal_msg);
293 LOG((
"Freeing args"));
294 while(!outgoing_args.empty()){
295 NS_Free(outgoing_args.back());
296 outgoing_args.pop_back();
299 dbus_connection_flush(mConn->get());
301 LOG((
"*****Signal Sent"));
308 NS_ENSURE_ARG_POINTER(handler);
317 NS_IMETHODIMP ngDBusConnection::GetInt64Arg(PRInt64 *_retval)
319 int type = dbus_message_iter_get_arg_type(&incoming_args);
321 if(type == DBUS_TYPE_INT64){
323 dbus_message_iter_get_basic(&incoming_args, &data);
324 dbus_message_iter_next(&incoming_args);
329 char* msg = PR_smprintf(
"WARNING: %i received but expecting a Int64", type);
331 PR_smprintf_free(msg);
338 NS_IMETHODIMP ngDBusConnection::GetBoolArg(PRBool *_retval)
340 int type = dbus_message_iter_get_arg_type(&incoming_args);
342 if(type == DBUS_TYPE_BOOLEAN){
344 dbus_message_iter_get_basic(&incoming_args, &data);
345 dbus_message_iter_next(&incoming_args);
350 char* msg = PR_smprintf(
"WARNING: %i received but expecting a Bool", type);
352 PR_smprintf_free(msg);
359 NS_IMETHODIMP ngDBusConnection::GetStringArg(
char **_retval)
362 int type = dbus_message_iter_get_arg_type(&incoming_args);
364 if(type == DBUS_TYPE_STRING){
366 dbus_message_iter_get_basic(&incoming_args, &dat);
370 *_retval = (
char*)NS_Alloc(
sizeof(
char)*(strlen(dat) + 1));
372 strcpy(*_retval, dat);
373 LOG((
"String contained %s", *_retval));
375 dbus_message_iter_next(&incoming_args);
379 char* msg = PR_smprintf(
"WARNING: %i received but expecting a String", type);
381 PR_smprintf_free(msg);
388 NS_IMETHODIMP ngDBusConnection::GetObjectPathArg(
char **_retval)
391 int type = dbus_message_iter_get_arg_type(&incoming_args);
393 if(type == DBUS_TYPE_OBJECT_PATH){
395 dbus_message_iter_get_basic(&incoming_args, &dat);
399 *_retval = (
char*)NS_Alloc(
sizeof(
char)*(strlen(dat) + 1));
401 strcpy(*_retval, dat);
403 dbus_message_iter_next(&incoming_args);
407 char* msg = PR_smprintf(
"WARNING: %i received but expecting a Object", type);
409 PR_smprintf_free(msg);
416 NS_IMETHODIMP ngDBusConnection::GetDoubleArg(PRFloat64 *_retval)
418 int type = dbus_message_iter_get_arg_type(&incoming_args);
420 if(type == DBUS_TYPE_DOUBLE){
422 dbus_message_iter_get_basic(&incoming_args, &data);
423 dbus_message_iter_next(&incoming_args);
428 char* msg = PR_smprintf(
"WARNING: %i received but expecting a Double", type);
430 PR_smprintf_free(msg);
437 NS_IMETHODIMP ngDBusConnection::GetArrayArg(nsIArray** _retval)
439 LOG((
"Getting array argument"));
442 nsCOMPtr<nsIMutableArray>
array = do_CreateInstance(
"@mozilla.org/array;1", &rv);
443 NS_ENSURE_SUCCESS(rv, rv);
444 int type = dbus_message_iter_get_arg_type(&incoming_args);
446 if(type == DBUS_TYPE_ARRAY){
447 DBusMessageIter
data;
450 dbus_message_iter_recurse(&incoming_args, &data);
451 while(dbus_message_iter_has_next(&data)) {
452 dbus_message_iter_get_basic(&data, &value);
453 type = dbus_message_iter_get_arg_type(&data);
454 dbus_message_iter_next(&data);
456 if(type == DBUS_TYPE_STRING || type == DBUS_TYPE_OBJECT_PATH) {
458 nsCOMPtr<nsISupportsString> stringVal = do_CreateInstance(
"@mozilla.org/supports-string;1", &rv);
459 NS_ENSURE_SUCCESS(rv, rv);
461 rv = stringVal->SetData(NS_ConvertUTF8toUTF16(NS_LITERAL_CSTRING(value.
string)));
462 NS_ENSURE_SUCCESS(rv, rv);
464 rv = array->AppendElement(stringVal,
false);
465 NS_ENSURE_SUCCESS(rv, rv);
468 rv = NS_ERROR_NOT_IMPLEMENTED;
472 dbus_message_iter_next(&incoming_args);
478 char* msg = PR_smprintf(
"WARNING: %i received but expecting an Array", type);
480 PR_smprintf_free(msg);;
483 LOG((
"Array argument got"));
489 NS_IMETHODIMP ngDBusConnection::SetInt32Arg(PRInt32
val)
491 LOG((
"Setting Int32 %d", val));
492 DBusMessageIter*
args = outgoing_args.back();
494 dbus_int32_t data =
val;
495 dbus_message_iter_append_basic(args, DBUS_TYPE_INT32, &data);
504 NS_IMETHODIMP ngDBusConnection::SetUInt32Arg(PRUint32 val)
506 LOG((
"Setting uInt32 %d", val));
508 DBusMessageIter* args = outgoing_args.back();
510 dbus_message_iter_append_basic(args, DBUS_TYPE_UINT32, &val);
518 NS_IMETHODIMP ngDBusConnection::SetUInt16Arg(PRUint16 val)
520 LOG((
"Set uInt16 %d", val));
521 DBusMessageIter* args = outgoing_args.back();
523 dbus_uint16_t data =
val;
524 dbus_message_iter_append_basic(args, DBUS_TYPE_UINT16, &data);
532 NS_IMETHODIMP ngDBusConnection::SetStringArg(
const nsAString& val)
534 DBusMessageIter* args = outgoing_args.back();
536 NS_ConvertUTF16toUTF8_external val8(val);
537 const char* data = val8.BeginReading();
538 LOG((
"Setting string %s", data));
540 dbus_message_iter_append_basic(args, DBUS_TYPE_STRING, &data);
547 NS_IMETHODIMP ngDBusConnection::SetDictSSEntryArg(
const char *
key,
const nsAString &val)
549 NS_ENSURE_ARG_POINTER(key);
551 DBusMessageIter* array_obj = outgoing_args.back();
552 DBusMessageIter entry_obj;
553 DBusMessageIter var_obj;
555 NS_ConvertUTF16toUTF8_external val8(val);
556 const char* data = val8.BeginReading();
558 LOG((
"Setting dict SS %s:%s", key, data));
560 dbus_message_iter_open_container(array_obj, DBUS_TYPE_DICT_ENTRY, NULL, &entry_obj);
561 dbus_message_iter_append_basic(&entry_obj, DBUS_TYPE_STRING, &key);
563 dbus_message_iter_open_container(&entry_obj, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &var_obj);
564 dbus_message_iter_append_basic(&var_obj, DBUS_TYPE_STRING, &data);
565 dbus_message_iter_close_container(&entry_obj, &var_obj);
566 dbus_message_iter_close_container(array_obj, &entry_obj);
568 LOG((
"Set dict SS entry"));
574 NS_IMETHODIMP ngDBusConnection::SetDictSOEntryArg(
const char *key,
const nsAString& val)
576 NS_ENSURE_ARG_POINTER(key);
578 DBusMessageIter* array_obj = outgoing_args.back();
579 DBusMessageIter entry_obj;
580 DBusMessageIter var_obj;
582 NS_ConvertUTF16toUTF8_external val8(val);
583 const char* data = val8.BeginReading();
585 LOG((
"Setting dict SO %s:%s", key, data));
587 dbus_message_iter_open_container(array_obj, DBUS_TYPE_DICT_ENTRY, NULL, &entry_obj);
588 dbus_message_iter_append_basic(&entry_obj, DBUS_TYPE_STRING, &key);
590 dbus_message_iter_open_container(&entry_obj, DBUS_TYPE_VARIANT, DBUS_TYPE_OBJECT_PATH_AS_STRING, &var_obj);
591 dbus_message_iter_append_basic(&var_obj, DBUS_TYPE_OBJECT_PATH, &data);
592 dbus_message_iter_close_container(&entry_obj, &var_obj);
593 dbus_message_iter_close_container(array_obj, &entry_obj);
595 LOG((
"Set dict SO entry"));
601 NS_IMETHODIMP ngDBusConnection::SetDictSI64EntryArg(
const char *key, PRInt64 val)
603 NS_ENSURE_ARG_POINTER(key);
604 LOG((
"Setting dict SI64 %s:%d", key, val));
606 DBusMessageIter* array_obj = outgoing_args.back();
607 DBusMessageIter entry_obj;
608 DBusMessageIter var_obj;
610 dbus_message_iter_open_container(array_obj, DBUS_TYPE_DICT_ENTRY, NULL, &entry_obj);
611 dbus_message_iter_append_basic(&entry_obj, DBUS_TYPE_STRING, &key);
613 dbus_message_iter_open_container(&entry_obj, DBUS_TYPE_VARIANT, DBUS_TYPE_INT64_AS_STRING, &var_obj);
614 dbus_message_iter_append_basic(&var_obj, DBUS_TYPE_INT64, &val);
615 dbus_message_iter_close_container(&entry_obj, &var_obj);
616 dbus_message_iter_close_container(array_obj, &entry_obj);
618 LOG((
"Set dict SI64 entry"));
624 NS_IMETHODIMP ngDBusConnection::SetDictSIEntryArg(
const char *key, PRUint32 val)
626 NS_ENSURE_ARG_POINTER(key);
627 LOG((
"Setting dict SI %s:%d", key, val));
629 DBusMessageIter* array_obj = outgoing_args.back();
630 DBusMessageIter entry_obj;
631 DBusMessageIter var_obj;
633 dbus_message_iter_open_container(array_obj, DBUS_TYPE_DICT_ENTRY, NULL, &entry_obj);
634 dbus_message_iter_append_basic(&entry_obj, DBUS_TYPE_STRING, &key);
636 dbus_message_iter_open_container(&entry_obj, DBUS_TYPE_VARIANT, DBUS_TYPE_UINT32_AS_STRING, &var_obj);
637 dbus_message_iter_append_basic(&var_obj, DBUS_TYPE_UINT32, &val);
638 dbus_message_iter_close_container(&entry_obj, &var_obj);
639 dbus_message_iter_close_container(array_obj, &entry_obj);
641 LOG((
"Set dict SI entry"));
647 NS_IMETHODIMP ngDBusConnection::SetDictSBEntryArg(
const char *key, PRBool val)
649 NS_ENSURE_ARG_POINTER(key);
650 LOG((
"Setting dict SB %s:%i", key, val));
652 DBusMessageIter* array_obj = outgoing_args.back();
653 DBusMessageIter entry_obj;
654 DBusMessageIter var_obj;
656 dbus_message_iter_open_container(array_obj, DBUS_TYPE_DICT_ENTRY, NULL, &entry_obj);
657 dbus_message_iter_append_basic(&entry_obj, DBUS_TYPE_STRING, &key);
659 dbus_message_iter_open_container(&entry_obj, DBUS_TYPE_VARIANT, DBUS_TYPE_BOOLEAN_AS_STRING, &var_obj);
660 dbus_message_iter_append_basic(&var_obj, DBUS_TYPE_BOOLEAN, &val);
661 dbus_message_iter_close_container(&entry_obj, &var_obj);
662 dbus_message_iter_close_container(array_obj, &entry_obj);
664 LOG((
"Set dict SB entry"));
670 NS_IMETHODIMP ngDBusConnection::SetDictSDEntryArg(
const char *key, PRFloat64 val)
672 NS_ENSURE_ARG_POINTER(key);
673 LOG((
"Setting dict SD %s:%f", key, val));
675 DBusMessageIter* array_obj = outgoing_args.back();
676 DBusMessageIter entry_obj;
677 DBusMessageIter var_obj;
679 dbus_message_iter_open_container(array_obj, DBUS_TYPE_DICT_ENTRY, NULL, &entry_obj);
680 dbus_message_iter_append_basic(&entry_obj, DBUS_TYPE_STRING, &key);
683 dbus_message_iter_open_container(&entry_obj, DBUS_TYPE_VARIANT, DBUS_TYPE_DOUBLE_AS_STRING, &var_obj);
684 dbus_message_iter_append_basic(&var_obj, DBUS_TYPE_DOUBLE, &data);
685 dbus_message_iter_close_container(&entry_obj, &var_obj);
686 dbus_message_iter_close_container(array_obj, &entry_obj);
688 LOG((
"Set dict SD entry"));
694 NS_IMETHODIMP ngDBusConnection::OpenDictSAEntryArg(
const char *key, PRInt16 aType = TYPE_STRING)
696 NS_ENSURE_ARG_POINTER(key);
697 LOG((
"Opening dict SA : %s", key));
700 DBusMessageIter* array_obj = outgoing_args.back();
701 DBusMessageIter* entry_obj = (DBusMessageIter*)NS_Alloc(
sizeof(DBusMessageIter));
703 DBusMessageIter* new_val = (DBusMessageIter*)NS_Alloc(
sizeof(DBusMessageIter));;
705 dbus_message_iter_open_container(array_obj, DBUS_TYPE_DICT_ENTRY, NULL, entry_obj);
706 dbus_message_iter_append_basic(entry_obj, DBUS_TYPE_STRING, &key);
708 char combinedType[strlen(DBUS_TYPE_ARRAY_AS_STRING) + strlen(this->ngTypeToDBusType(aType)) + 1];
709 combinedType[0] =
'\0';
710 strcat(combinedType, DBUS_TYPE_ARRAY_AS_STRING);
711 strcat(combinedType, this->ngTypeToDBusType(aType));
713 dbus_message_iter_open_container(entry_obj, DBUS_TYPE_VARIANT, combinedType, new_val);
715 outgoing_args.push_back(entry_obj);
716 outgoing_args.push_back(new_val);
718 rv = this->OpenArray(aType);
719 NS_ENSURE_SUCCESS(rv, rv);
721 LOG((
"Opened dict SA entry"));
727 NS_IMETHODIMP ngDBusConnection::CloseDictSAEntryArg()
729 LOG((
"Closing dict SA "));
732 rv = this->CloseArray();
733 NS_ENSURE_SUCCESS(rv, rv);
735 DBusMessageIter* new_val = outgoing_args.back();
736 outgoing_args.pop_back();
737 DBusMessageIter* entry_obj = outgoing_args.back();
738 outgoing_args.pop_back();
739 DBusMessageIter* array_obj = outgoing_args.back();
741 dbus_message_iter_close_container(entry_obj, new_val);
742 dbus_message_iter_close_container(array_obj, entry_obj);
744 LOG((
"Closed dict SA entry"));
749 NS_IMETHODIMP ngDBusConnection::OpenDictSDEntryArg(
const char *key)
751 NS_ENSURE_ARG_POINTER(key);
752 LOG((
"Opening dict SD :%s", key));
754 DBusMessageIter* array_obj = outgoing_args.back();
755 DBusMessageIter* entry_obj = (DBusMessageIter*)NS_Alloc(
sizeof(DBusMessageIter));
757 DBusMessageIter* new_val = (DBusMessageIter*)NS_Alloc(
sizeof(DBusMessageIter));
758 DBusMessageIter* new_arr = (DBusMessageIter*)NS_Alloc(
sizeof(DBusMessageIter));
760 dbus_message_iter_open_container(array_obj, DBUS_TYPE_DICT_ENTRY, NULL, entry_obj);
761 dbus_message_iter_append_basic(entry_obj, DBUS_TYPE_STRING, &key);
763 dbus_message_iter_open_container(entry_obj, DBUS_TYPE_VARIANT, DBUS_TYPE_ARRAY_AS_STRING DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, new_val);
764 dbus_message_iter_open_container(new_val, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, new_arr);
766 outgoing_args.push_back(entry_obj);
767 outgoing_args.push_back(new_val);
768 outgoing_args.push_back(new_arr);
770 LOG((
"Opened dict SD entry"));
776 NS_IMETHODIMP ngDBusConnection::CloseDictSDEntryArg()
778 LOG((
"Closing dict SD "));
780 DBusMessageIter* new_arr = outgoing_args.back();
781 outgoing_args.pop_back();
782 DBusMessageIter* new_val = outgoing_args.back();
783 outgoing_args.pop_back();
784 DBusMessageIter* entry_obj = outgoing_args.back();
785 outgoing_args.pop_back();
786 DBusMessageIter* array_obj = outgoing_args.back();
788 dbus_message_iter_close_container(new_val, new_arr);
789 dbus_message_iter_close_container(entry_obj, new_val);
790 dbus_message_iter_close_container(array_obj, entry_obj);
792 LOG((
"Closed dict SD entry"));
799 NS_IMETHODIMP ngDBusConnection::SetBoolArg(PRBool val)
801 LOG((
"Setting Bool %i", val));
802 DBusMessageIter* args = outgoing_args.back();
804 dbus_bool_t data =
val;
805 dbus_message_iter_append_basic(args, DBUS_TYPE_BOOLEAN, &data);
813 NS_IMETHODIMP ngDBusConnection::SetDoubleArg(PRFloat64 val)
815 LOG((
"Set Double %f", val));
816 DBusMessageIter* args = outgoing_args.back();
819 dbus_message_iter_append_basic(args, DBUS_TYPE_DOUBLE, &data);
826 NS_IMETHODIMP ngDBusConnection::SetInt64Arg(PRInt64 val)
828 LOG((
"Set Int64 %d", val));
829 DBusMessageIter* args = outgoing_args.back();
831 dbus_int64_t data =
val;
832 dbus_message_iter_append_basic(args, DBUS_TYPE_INT64, &data);
839 NS_IMETHODIMP ngDBusConnection::SetArrayStringArg(
const nsAString& val)
841 return this->SetStringArg(val);
846 NS_IMETHODIMP ngDBusConnection::SetObjectPathArg(
const char *data)
848 NS_ENSURE_ARG_POINTER(data);
849 DBusMessageIter* args = outgoing_args.back();
851 LOG((
"Setting object path %s", data));
853 dbus_message_iter_append_basic(args, DBUS_TYPE_OBJECT_PATH, &data);
855 LOG((
"Set object path"));
860 NS_IMETHODIMP ngDBusConnection::OpenDictEntryArray()
862 LOG((
"Opening dict entry"));
864 DBusMessageIter* args = outgoing_args.back();
865 DBusMessageIter* new_args = (DBusMessageIter*)NS_Alloc(
sizeof(DBusMessageIter));
867 dbus_message_iter_open_container(args, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, new_args);
869 outgoing_args.push_back(new_args);
871 LOG((
"Dict entry open"));
876 NS_IMETHODIMP ngDBusConnection::CloseDictEntryArray()
878 LOG((
"Closing dict entry"));
880 DBusMessageIter* new_args = outgoing_args.back();
881 outgoing_args.pop_back();
882 DBusMessageIter* args = outgoing_args.back();
884 dbus_message_iter_close_container(args, new_args);
886 LOG((
"Dict entry closed"));
891 NS_IMETHODIMP ngDBusConnection::OpenArray(PRInt16 aType = TYPE_STRING)
893 LOG((
"Opening array"));
895 DBusMessageIter* args = outgoing_args.back();
896 DBusMessageIter* new_args = (DBusMessageIter*)NS_Alloc(
sizeof(DBusMessageIter));
898 dbus_message_iter_open_container(args, DBUS_TYPE_ARRAY, this->ngTypeToDBusType(aType), new_args);
900 outgoing_args.push_back(new_args);
907 NS_IMETHODIMP ngDBusConnection::CloseArray()
909 LOG((
"Closing array"));
911 DBusMessageIter* new_args = outgoing_args.back();
912 outgoing_args.pop_back();
913 DBusMessageIter* args = outgoing_args.back();
915 dbus_message_iter_close_container(args, new_args);
917 LOG((
"Array closed"));
922 NS_IMETHODIMP ngDBusConnection::OpenStruct()
924 LOG((
"Opening struct"));
926 DBusMessageIter* args = outgoing_args.back();
927 DBusMessageIter* new_args = (DBusMessageIter*)NS_Alloc(
sizeof(DBusMessageIter));
929 dbus_message_iter_open_container(args, DBUS_TYPE_STRUCT, NULL, new_args);
931 outgoing_args.push_back(new_args);
932 LOG((
"Struct opened"));
938 NS_IMETHODIMP ngDBusConnection::CloseStruct()
940 LOG((
"Closing struct"));
941 DBusMessageIter* new_args = outgoing_args.back();
942 outgoing_args.pop_back();
943 DBusMessageIter* args = outgoing_args.back();
945 dbus_message_iter_close_container(args, new_args);
946 LOG((
"Struct closed"));
951 const char* ngDBusConnection::ngTypeToDBusType(
const int ngType)
const
953 if(ngType == TYPE_OBJECT_PATH) {
954 return DBUS_TYPE_OBJECT_PATH_AS_STRING;
957 return DBUS_TYPE_STRING_AS_STRING;
static nsresult New(sbDBusConnection **aConnection, DBusBusType aBusType, const char *aDestination, const char *aPath, const char *aInterface)
NS_IMPL_ISUPPORTS2(sbAlbumArtService, sbIAlbumArtService, nsIObserver) NS_IMETHODIMP sbAlbumArtService
this _dialogInput val(dateText)
const NS_TIMER_CALLBACK_TOPIC
ExtensionSchemeMatcher prototype match
virtual ~ngDBusConnection()
Songbird D-Bus Service Definitions.
#define SB_DBUS_ENSURE_SUCCESS(aError, aReturnValue)
_updateTextAndScrollDataForFrame aData