Change dbus 'listDevices' call to not require an argument.
Update dbus-api documentation, plug memory leak on dbus reply error.
This commit is contained in:
		
							parent
							
								
									b6aec7f6f9
								
							
						
					
					
						commit
						ae75afcb1b
					
				|  | @ -280,11 +280,6 @@ configMessage(DBusConnection *connection, DBusMessage *message, void *closure) | ||||||
| 
 | 
 | ||||||
|     if (strcmp(dbus_message_get_interface(message), |     if (strcmp(dbus_message_get_interface(message), | ||||||
|                "org.x.config.input") == 0) { |                "org.x.config.input") == 0) { | ||||||
|         if (!dbus_message_iter_init(message, &iter)) { |  | ||||||
|             ErrorF("[config] failed to init iterator\n"); |  | ||||||
|             dbus_error_free(&error); |  | ||||||
|             return DBUS_HANDLER_RESULT_NEED_MEMORY; /* ?? */ |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         if (!(reply = dbus_message_new_method_return(message))) { |         if (!(reply = dbus_message_new_method_return(message))) { | ||||||
|             ErrorF("[config] failed to create the reply message\n"); |             ErrorF("[config] failed to create the reply message\n"); | ||||||
|  | @ -292,18 +287,30 @@ configMessage(DBusConnection *connection, DBusMessage *message, void *closure) | ||||||
|             return DBUS_HANDLER_RESULT_NEED_MEMORY; |             return DBUS_HANDLER_RESULT_NEED_MEMORY; | ||||||
|         } |         } | ||||||
|         dbus_message_iter_init_append(reply, &r_iter); |         dbus_message_iter_init_append(reply, &r_iter); | ||||||
|          |  | ||||||
|         if (strcmp(dbus_message_get_member(message), "add") == 0) |  | ||||||
|             ret = configAddDevice(message, &iter, reply, &r_iter, &error); |  | ||||||
|         else if (strcmp(dbus_message_get_member(message), "remove") == 0) |  | ||||||
|             ret = configRemoveDevice(message, &iter, &error); |  | ||||||
|         else if (strcmp(dbus_message_get_member(message), "listDevices") == 0) |  | ||||||
|             ret = configListDevices(message, &iter, reply, &r_iter, &error); |  | ||||||
|         if (ret != BadDrawable && ret != BadAlloc) { |  | ||||||
| 
 | 
 | ||||||
|  |         /* listDevices doesn't take any arguments */ | ||||||
|  |         if (strcmp(dbus_message_get_member(message), "listDevices") == 0) | ||||||
|  |             ret = configListDevices(message, NULL, reply, &r_iter, &error); | ||||||
|  |         else  | ||||||
|  |         { | ||||||
|  |             if (!dbus_message_iter_init(message, &iter)) { | ||||||
|  |                 ErrorF("[config] failed to init iterator\n"); | ||||||
|  |                 dbus_message_unref(reply); | ||||||
|  |                 dbus_error_free(&error); | ||||||
|  |                 return DBUS_HANDLER_RESULT_NEED_MEMORY; /* ?? */ | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if (strcmp(dbus_message_get_member(message), "add") == 0) | ||||||
|  |                 ret = configAddDevice(message, &iter, reply, &r_iter, &error); | ||||||
|  |             else if (strcmp(dbus_message_get_member(message), "remove") == 0) | ||||||
|  |                 ret = configRemoveDevice(message, &iter, &error); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if (ret != BadDrawable && ret != BadAlloc) { | ||||||
|             if (!strlen(dbus_message_get_signature(reply))) |             if (!strlen(dbus_message_get_signature(reply))) | ||||||
|                 if (!dbus_message_iter_append_basic(&r_iter, DBUS_TYPE_INT32, &ret)) { |                 if (!dbus_message_iter_append_basic(&r_iter, DBUS_TYPE_INT32, &ret)) { | ||||||
|                     ErrorF("[config] couldn't append to iterator\n"); |                     ErrorF("[config] couldn't append to iterator\n"); | ||||||
|  |                     dbus_message_unref(reply); | ||||||
|                     dbus_error_free(&error); |                     dbus_error_free(&error); | ||||||
|                     return DBUS_HANDLER_RESULT_HANDLED; |                     return DBUS_HANDLER_RESULT_HANDLED; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|  | @ -33,3 +33,7 @@ org.x.config.input: | ||||||
|          i |          i | ||||||
|         is the signature. |         is the signature. | ||||||
|         Same return values as org.x.config.input.add. |         Same return values as org.x.config.input.add. | ||||||
|  | 
 | ||||||
|  |     org.x.config.input.listDevices: | ||||||
|  |         Lists the currently active devices. | ||||||
|  |         Return value is sequence of <id> <name> <id> <name> ... | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue