db3f6002fe9e8a9ccd40d4eb1f00c4fbc17da8fc
[platform/core/multimedia/libmm-sound.git] / common / mm_sound_dbus.c
1
2 #include <gio/gio.h>
3 #include <stdlib.h>
4
5 #include <mm_error.h>
6 #include <mm_debug.h>
7
8 #include "../include/mm_sound_dbus.h"
9 #include "../include/mm_sound_intf.h"
10
11 struct callback_data {
12         mm_sound_dbus_callback user_cb;
13         void *user_data;
14         mm_sound_dbus_userdata_free free_func;
15 };
16
17 struct dbus_path {
18         char *bus_name;
19         char *object;
20         char *interface;
21 };
22
23 const struct dbus_path g_paths[AUDIO_PROVIDER_MAX] = {
24         [AUDIO_PROVIDER_SOUND_SERVER] = {
25                 .bus_name = "org.tizen.SoundServer",
26                 .object = "/org/tizen/SoundServer1",
27                 .interface = "org.tizen.SoundServer1"
28         },
29         [AUDIO_PROVIDER_FOCUS_SERVER] = {
30                 .bus_name = "org.tizen.FocusServer",
31                 .object = "/org/tizen/FocusServer1",
32                 .interface = "org.tizen.FocusServer1"
33         },
34         [AUDIO_PROVIDER_DEVICE_MANAGER] = {
35                 .bus_name = "org.pulseaudio.Server",
36                 .object = "/org/pulseaudio/DeviceManager",
37                 .interface = "org.pulseaudio.DeviceManager"
38         },
39         [AUDIO_PROVIDER_STREAM_MANAGER] = {
40                 .bus_name = "org.pulseaudio.Server",
41                 .object = "/org/pulseaudio/StreamManager",
42                 .interface = "org.pulseaudio.StreamManager"
43         },
44         [AUDIO_PROVIDER_AUDIO_CLIENT] = {
45                 .bus_name = "org.tizen.AudioClient",
46                 .object = "/org/tizen/AudioClient1",
47                 .interface = "org.tizen.AudioClient1"
48         }
49 };
50
51 const mm_sound_dbus_method_info_t g_methods[AUDIO_METHOD_MAX] = {
52         [AUDIO_METHOD_TEST] = {
53                 .name = "MethodTest1",
54         },
55         [AUDIO_METHOD_PLAY_FILE_START_WITH_STREAM_INFO] = {
56                 .name = "PlayFileStartWithStreamInfo",
57         },
58         [AUDIO_METHOD_PLAY_FILE_STOP] = {
59                 .name = "PlayFileStop",
60         },
61         [AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO] = {
62                 .name = "PlayDTMFWithStreamInfo",
63         },
64         [AUDIO_METHOD_SET_VOLUME_LEVEL] = {
65                 .name = "SetVolumeLevel",
66         },
67         [AUDIO_METHOD_GET_CONNECTED_DEVICE_LIST] = {
68                 .name = "GetConnectedDeviceList",
69         },
70         [AUDIO_METHOD_GET_DEVICE_BY_ID] = {
71                 .name = "GetDeviceById",
72         },
73         [AUDIO_METHOD_IS_STREAM_ON_DEVICE] = {
74                 .name = "IsStreamOnDevice",
75         },
76         [AUDIO_METHOD_GET_UNIQUE_ID] = {
77                 .name = "GetUniqueId",
78         },
79         [AUDIO_METHOD_REGISTER_FOCUS] = {
80                 .name = "RegisterFocus",
81         },
82         [AUDIO_METHOD_UNREGISTER_FOCUS] = {
83                 .name = "UnregisterFocus",
84         },
85         [AUDIO_METHOD_SET_FOCUS_REACQUISITION] = {
86                 .name = "SetFocusReacquisition",
87         },
88         [AUDIO_METHOD_GET_ACQUIRED_FOCUS_STREAM_TYPE] = {
89                 .name = "GetAcquiredFocusStreamType",
90         },
91         [AUDIO_METHOD_ACQUIRE_FOCUS] = {
92                 .name = "AcquireFocus",
93         },
94         [AUDIO_METHOD_RELEASE_FOCUS] = {
95                 .name = "ReleaseFocus",
96         },
97         [AUDIO_METHOD_UPDATE_STREAM_FOCUS_STATUS] = {
98                 .name = "UpdateFocusStatusByFocusId",
99         },
100         [AUDIO_METHOD_WATCH_FOCUS] = {
101                 .name = "WatchFocus",
102         },
103         [AUDIO_METHOD_UNWATCH_FOCUS] = {
104                 .name = "UnwatchFocus",
105         },
106         [AUDIO_METHOD_DELIVER_FOCUS] = {
107                 .name = "DeliverFocus",
108         },
109         [AUDIO_METHOD_SET_FILTER] = {
110                 .name = "SetFilter",
111         },
112         [AUDIO_METHOD_UNSET_FILTER] = {
113                 .name = "UnsetFilter",
114         },
115         [AUDIO_METHOD_CONTROL_FILTER] = {
116                 .name = "ControlFilter",
117         },
118 };
119
120 const mm_sound_dbus_signal_info_t g_events[AUDIO_EVENT_MAX] = {
121         [AUDIO_EVENT_TEST] = {
122                 .name = "SignalTest1",
123         },
124         [AUDIO_EVENT_PLAY_FILE_END] = {
125                 .name = "PlayFileEnd",
126         },
127         [AUDIO_EVENT_VOLUME_CHANGED] = {
128                 .name = "VolumeChanged",
129         },
130         [AUDIO_EVENT_DEVICE_CONNECTED] = {
131                 .name = "DeviceConnected",
132         },
133         [AUDIO_EVENT_DEVICE_INFO_CHANGED] = {
134                 .name = "DeviceInfoChanged",
135         },
136         [AUDIO_EVENT_DEVICE_STATE_CHANGED] = {
137                 .name = "DeviceStateChanged",
138         },
139         [AUDIO_EVENT_DEVICE_RUNNING_CHANGED] = {
140                 .name = "DeviceRunningChanged",
141         },
142         [AUDIO_EVENT_FOCUS_CHANGED] = {
143                 .name = "FocusChanged",
144         },
145         [AUDIO_EVENT_FOCUS_WATCH] = {
146                 .name = "FocusWatch",
147         },
148         [AUDIO_EVENT_EMERGENT_EXIT] = {
149                 .name = "EmergentExit",
150         },
151         [AUDIO_EVENT_CLIENT_SUBSCRIBED] = {
152                 .name = "ClientSubscribed",
153         },
154         [AUDIO_EVENT_CLIENT_HANDLED] = {
155                 .name = "ClientSignalHandled",
156         }
157 };
158
159 /* Only For error types which is currently being used in server-side */
160 static const GDBusErrorEntry mm_sound_error_entries[] = {
161         {MM_ERROR_OUT_OF_MEMORY, "org.tizen.multimedia.OutOfMemory"},
162         {MM_ERROR_OUT_OF_STORAGE, "org.tizen.multimedia.OutOfStorage"},
163         {MM_ERROR_INVALID_ARGUMENT, "org.tizen.multimedia.InvalidArgument"},
164         {MM_ERROR_POLICY_INTERNAL, "org.tizen.multimedia.PolicyInternal"},
165         {MM_ERROR_NOT_SUPPORT_API, "org.tizen.multimedia.NotSupportAPI"},
166         {MM_ERROR_POLICY_BLOCKED, "org.tizen.multimedia.PolicyBlocked"},
167         {MM_ERROR_END_OF_FILE, "org.tizen.multimedia.EndOfFile"},
168         {MM_ERROR_COMMON_OUT_OF_RANGE, "org.tizen.multimedia.common.OutOfRange"},
169         {MM_ERROR_COMMON_UNKNOWN, "org.tizen.multimedia.common.Unknown"},
170         {MM_ERROR_COMMON_NO_FREE_SPACE, "org.tizen.multimedia.common.NoFreeSpace"},
171         {MM_ERROR_SOUND_INTERNAL, "org.tizen.multimedia.audio.Internal"},
172         {MM_ERROR_SOUND_INVALID_STATE, "org.tizen.multimedia.audio.InvalidState"},
173         {MM_ERROR_SOUND_NO_FREE_SPACE, "org.tizen.multimedia.audio.NoFreeSpace"},
174         {MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE, "org.tizen.multimedia.audio.UnsupportedMediaType"},
175         {MM_ERROR_SOUND_INVALID_POINTER, "org.tizen.multimedia.audio.InvalidPointer"},
176         {MM_ERROR_SOUND_INVALID_FILE, "org.tizen.multimedia.audio.InvalidFile"},
177         {MM_ERROR_SOUND_FILE_NOT_FOUND, "org.tizen.multimedia.audio.FileNotFound"},
178         {MM_ERROR_SOUND_NO_DATA, "org.tizen.multimedia.audio.NoData"},
179         {MM_ERROR_SOUND_INVALID_PATH, "org.tizen.multimedia.audio.InvalidPath"},
180         {MM_ERROR_SOUND_PERMISSION_DENIED, "org.freedesktop.DBus.Error.AccessDenied"},
181 };
182
183
184 /******************************************************************************************
185                 Wrapper Functions of GDbus
186 ******************************************************************************************/
187
188 static int _parse_error_msg(char *full_err_msg, char **err_name, char **err_msg)
189 {
190         char *save_p = NULL, *domain, *_err_name, *_err_msg;
191
192         if (!(domain = strtok_r(full_err_msg, ":", &save_p))) {
193                 debug_error("get domain failed");
194                 return -1;
195         }
196         if (!(_err_name = strtok_r(NULL, ":", &save_p))) {
197                 debug_error("get err name failed");
198                 return -1;
199         }
200         if (!(_err_msg = strtok_r(NULL, ":", &save_p))) {
201                 debug_error("get err msg failed");
202                 return -1;
203         }
204
205         *err_name = _err_name;
206         *err_msg = _err_msg;
207
208         return 0;
209 }
210
211 static int _convert_error_name(const char *err_name)
212 {
213         int i = 0;
214
215         debug_error("error name is [%s]", err_name);
216
217         for (i = 0; i < G_N_ELEMENTS(mm_sound_error_entries); i++) {
218                 if (!strcmp(mm_sound_error_entries[i].dbus_error_name, err_name))
219                         return mm_sound_error_entries[i].error_code;
220         }
221
222         return MM_ERROR_COMMON_UNKNOWN;
223 }
224
225 static int _dbus_method_call(GDBusConnection *conn, const char *bus_name, const char *object, const char *intf,
226                                                         const char *method, GVariant *args, GVariant **result)
227 {
228         int ret = MM_ERROR_NONE;
229         GError *err = NULL;
230         GVariant *dbus_reply = NULL;
231
232         if (!conn || !object || !intf || !method) {
233                 debug_error("Invalid Argument");
234                 if (!conn)
235                         debug_error("conn null");
236                 if (!object)
237                         debug_error("object null");
238                 if (!intf)
239                         debug_error("intf null");
240                 if (!method)
241                         debug_error("method null");
242                 return MM_ERROR_INVALID_ARGUMENT;
243         }
244
245         debug_log("Dbus call with obj'%s' intf'%s' method'%s'", object, intf, method);
246
247         dbus_reply = g_dbus_connection_call_sync(conn, bus_name, object , intf,
248                                                                                         method, args ,
249                                                                                         NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
250
251         if (!dbus_reply || err) {
252                 char *err_name = NULL, *err_msg = NULL;
253                 debug_error("Method Call '%s.%s' Failed, %s", intf, method, err ? err->message : NULL);
254                 ret = MM_ERROR_SOUND_INTERNAL;
255                 if (err) {
256                         if (_parse_error_msg(err->message, &err_name, &err_msg) < 0) {
257                                 debug_error("failed to parse error message");
258                                 g_error_free(err);
259                                 return MM_ERROR_SOUND_INTERNAL;
260                         }
261                         ret = _convert_error_name(err_name);
262                 }
263                 g_error_free(err);
264         } else {
265                 debug_log("Method Call '%s.%s' Success", intf, method);
266         }
267
268         *result = dbus_reply;
269
270         return ret;
271 }
272
273 static int _dbus_subscribe_signal(GDBusConnection *conn, const char *object_name, const char *intf_name,
274                                                                 const char *signal_name, GDBusSignalCallback signal_cb, guint *subscribe_id,
275                                                                 void *userdata, GDestroyNotify freefunc)
276 {
277         guint subs_id = 0;
278
279         if (!conn || !object_name || !intf_name || !signal_name || !signal_cb) {
280                 debug_error("Invalid Argument");
281                 return MM_ERROR_INVALID_ARGUMENT;
282         }
283
284         debug_log("Dbus subscirbe signal with Obj'%s' Intf'%s' sig'%s'", object_name, intf_name, signal_name);
285
286         subs_id = g_dbus_connection_signal_subscribe(conn, NULL, intf_name, signal_name, object_name,
287                                                                                                 NULL, G_DBUS_SIGNAL_FLAGS_NONE , signal_cb, userdata, freefunc);
288
289         if (!subs_id) {
290                 debug_error("g_dbus_connection_signal_subscribe() failed ");
291                 return MM_ERROR_SOUND_INTERNAL;
292         }
293         if (subscribe_id)
294                 *subscribe_id = subs_id;
295
296         return MM_ERROR_NONE;
297 }
298
299 static void _dbus_unsubscribe_signal(GDBusConnection *conn, guint subs_id)
300 {
301         if (!conn || !subs_id) {
302                 debug_error("Invalid Argument");
303                 return;
304         }
305
306         g_dbus_connection_signal_unsubscribe(conn, subs_id);
307 }
308
309 static GDBusConnection * _dbus_get_connection(GBusType bustype)
310 {
311         static GDBusConnection *conn_system = NULL;
312         static GDBusConnection *conn_session = NULL;
313         GError *err = NULL;
314
315         if (bustype == G_BUS_TYPE_SYSTEM) {
316                 if (conn_system) {
317 #ifndef TIZEN_TV
318                         debug_log("Already connected to system bus");
319 #endif
320                 } else {
321 #ifndef TIZEN_TV
322                         debug_log("Get new connection on system bus");
323 #endif
324                         conn_system = g_bus_get_sync(bustype, NULL, &err);
325                         if (!conn_system || err) {
326 #ifndef TIZEN_TV
327                                 debug_error("g_dbus_get_sync() error (%s)", err ? err->message : NULL);
328 #endif
329                                 g_error_free(err);
330                                 return NULL;
331                         }
332                 }
333                 return conn_system;
334         } else if (bustype == G_BUS_TYPE_SESSION) {
335                 if (conn_session) {
336 #ifndef TIZEN_TV
337                         debug_log("Already connected to session bus");
338 #endif
339                 } else {
340 #ifndef TIZEN_TV
341                         debug_log("Get new connection on session bus");
342 #endif
343                         conn_session = g_bus_get_sync(bustype, NULL, &err);
344                         if (!conn_session || err) {
345 #ifndef TIZEN_TV
346                                 debug_error("g_dbus_get_sync() error (%s)", err ? err->message : NULL);
347 #endif
348                                 g_error_free(err);
349                                 return NULL;
350                         }
351                 }
352                 return conn_session;
353         } else {
354 #ifndef TIZEN_TV
355                 debug_error("Invalid bus type");
356 #endif
357                 return NULL;
358         }
359
360 }
361
362 /******************************************************************************************
363                 Simple Functions For Communicate with Sound-Server
364 ******************************************************************************************/
365
366 EXPORT_API
367 int mm_sound_dbus_method_call_to(audio_provider_t provider, audio_method_t method_type, GVariant *args, GVariant **result)
368 {
369         int ret = MM_ERROR_NONE;
370         GDBusConnection *conn = NULL;
371
372         if (method_type >= AUDIO_METHOD_MAX) {
373                 debug_error("Invalid method type : %d", method_type);
374                 return MM_ERROR_INVALID_ARGUMENT;
375         }
376         if (provider >= AUDIO_PROVIDER_MAX) {
377                 debug_error("Invalid provider : %d", provider);
378                 return MM_ERROR_INVALID_ARGUMENT;
379         }
380
381         if (!(conn = _dbus_get_connection(G_BUS_TYPE_SYSTEM))) {
382                 debug_error("Get Dbus Connection Error");
383                 return MM_ERROR_SOUND_INTERNAL;
384         }
385
386         if ((ret = _dbus_method_call(conn, g_paths[provider].bus_name,
387                                                                 g_paths[provider].object,
388                                                                 g_paths[provider].interface,
389                                                                 g_methods[method_type].name,
390                                                                 args, result)) != MM_ERROR_NONE) {
391                 debug_error("Dbus Call on Client Error");
392         }
393
394         return ret;
395 }
396
397 /* This callback only transform signal-callback to dbus non-related form (mm_sound_dbus_callback) */
398 static void _dbus_signal_callback(GDBusConnection *connection,
399                                                                 const gchar *sender_name,
400                                                                 const gchar *object_path,
401                                                                 const gchar *interface_name,
402                                                                 const gchar *signal_name,
403                                                                 GVariant *params,
404                                                                 gpointer userdata)
405 {
406         struct callback_data *cb_data = (struct callback_data *)userdata;
407
408         debug_log("Signal(%s.%s) Received, Let's call Wrapper-Callback", interface_name, signal_name);
409
410         if (!strcmp(signal_name, g_events[AUDIO_EVENT_VOLUME_CHANGED].name))
411                 (cb_data->user_cb)(AUDIO_EVENT_VOLUME_CHANGED, params, cb_data->user_data);
412         else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_CONNECTED].name))
413                 (cb_data->user_cb)(AUDIO_EVENT_DEVICE_CONNECTED, params, cb_data->user_data);
414         else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_INFO_CHANGED].name))
415                 (cb_data->user_cb)(AUDIO_EVENT_DEVICE_INFO_CHANGED, params, cb_data->user_data);
416         else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_STATE_CHANGED].name))
417                 (cb_data->user_cb)(AUDIO_EVENT_DEVICE_STATE_CHANGED, params, cb_data->user_data);
418         else if (!strcmp(signal_name, g_events[AUDIO_EVENT_FOCUS_CHANGED].name))
419                 (cb_data->user_cb)(AUDIO_EVENT_FOCUS_CHANGED, params, cb_data->user_data);
420         else if (!strcmp(signal_name, g_events[AUDIO_EVENT_FOCUS_WATCH].name))
421                 (cb_data->user_cb)(AUDIO_EVENT_FOCUS_WATCH, params, cb_data->user_data);
422         else if (!strcmp(signal_name, g_events[AUDIO_EVENT_PLAY_FILE_END].name))
423                 (cb_data->user_cb)(AUDIO_EVENT_PLAY_FILE_END, params, cb_data->user_data);
424         else if (!strcmp(signal_name, g_events[AUDIO_EVENT_EMERGENT_EXIT].name))
425                 (cb_data->user_cb)(AUDIO_EVENT_EMERGENT_EXIT, params, cb_data->user_data);
426         else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_RUNNING_CHANGED].name))
427                 (cb_data->user_cb)(AUDIO_EVENT_DEVICE_RUNNING_CHANGED, params, cb_data->user_data);
428 }
429
430 static void callback_data_free_func(gpointer data)
431 {
432         struct callback_data *cb_data = (struct callback_data *)data;
433
434         if (cb_data->free_func)
435                 cb_data->free_func(cb_data->user_data);
436         g_free(cb_data);
437 }
438
439 EXPORT_API
440 int mm_sound_dbus_signal_subscribe_to(audio_provider_t provider, audio_event_t event, mm_sound_dbus_callback callback,
441                                                                         void *userdata, mm_sound_dbus_userdata_free freefunc, unsigned *subs_id)
442 {
443         GDBusConnection *conn = NULL;
444         guint _subs_id = 0;
445         struct callback_data *cb_data = NULL;
446
447         if (!callback) {
448                 debug_error("Callback is Null");
449                 return MM_ERROR_INVALID_ARGUMENT;
450         }
451
452         if (event >= AUDIO_EVENT_MAX) {
453                 debug_error("Wrong event Type : %d", event);
454                 return MM_ERROR_INVALID_ARGUMENT;
455         }
456
457         if (provider >= AUDIO_PROVIDER_MAX) {
458                 debug_error("Invalid provider : %d", provider);
459                 return MM_ERROR_INVALID_ARGUMENT;
460         }
461
462         if (!(conn = _dbus_get_connection(G_BUS_TYPE_SYSTEM))) {
463                 debug_error("Get Dbus Connection Error");
464                 return MM_ERROR_SOUND_INTERNAL;
465         }
466
467         if (!(cb_data = (struct callback_data*)g_malloc0(sizeof(struct callback_data)))) {
468                 debug_error("Allocate for callback data failed");
469                 return MM_ERROR_SOUND_INTERNAL;
470         }
471
472         cb_data->user_cb = callback;
473         cb_data->user_data = userdata;
474         cb_data->free_func = freefunc;
475
476         if (_dbus_subscribe_signal(conn, g_paths[provider].object, g_paths[provider].interface, g_events[event].name,
477                                                         _dbus_signal_callback, &_subs_id, cb_data, callback_data_free_func) != MM_ERROR_NONE) {
478                 debug_error("Dbus Subscribe on Client Error");
479                 goto fail;
480         }
481         if (subs_id)
482                 *subs_id = (unsigned int)_subs_id;
483
484         return MM_ERROR_NONE;
485
486 fail:
487         free(cb_data);
488         return MM_ERROR_SOUND_INTERNAL;
489 }
490
491 EXPORT_API
492 int mm_sound_dbus_signal_unsubscribe(unsigned int subs_id)
493 {
494         GDBusConnection *conn = NULL;
495
496         if (!(conn = _dbus_get_connection(G_BUS_TYPE_SYSTEM))) {
497                 debug_error("Get Dbus Connection Error");
498                 return MM_ERROR_SOUND_INTERNAL;
499         }
500
501         _dbus_unsubscribe_signal(conn, (guint)subs_id);
502
503         return MM_ERROR_NONE;
504 }
505
506 EXPORT_API
507 int mm_sound_dbus_emit_signal(audio_provider_t provider, audio_event_t event, GVariant *param)
508 {
509         GDBusConnection *conn;
510         GError *err = NULL;
511         gboolean dbus_ret;
512
513         if (event >= AUDIO_EVENT_MAX) {
514 #ifndef TIZEN_TV
515                 debug_error("emit signal failed, invalid argument, event_type(%d)", event);
516 #endif
517                 return MM_ERROR_INVALID_ARGUMENT;
518         }
519
520         if (!(conn = _dbus_get_connection(G_BUS_TYPE_SYSTEM))) {
521 #ifndef TIZEN_TV
522                 debug_error("Get Dbus Connection Error");
523 #endif
524                 return MM_ERROR_SOUND_INTERNAL;
525         }
526
527         dbus_ret = g_dbus_connection_emit_signal(conn,
528                                                   NULL, g_paths[provider].object,
529                                                   g_paths[provider].interface, g_events[event].name,
530                                                   param, &err);
531         if (!dbus_ret || err) {
532 #ifndef TIZEN_TV
533                 debug_error("g_dbus_connection_emit_signal() error (%s)", err ? err->message : NULL);
534 #endif
535                 g_error_free(err);
536                 return MM_ERROR_SOUND_INTERNAL;
537         }
538         g_dbus_connection_flush_sync(conn, NULL, NULL);
539
540 #ifndef TIZEN_TV
541         debug_msg("emit signal for [%s] success", g_events[event].name);
542 #endif
543         return MM_ERROR_NONE;
544 }
545
546 EXPORT_API
547 int mm_sound_dbus_get_event_name(audio_event_t event, const char **event_name)
548 {
549         if (!event_name) {
550                 debug_error("Invalid Parameter, event_name NULL");
551                 return MM_ERROR_INVALID_ARGUMENT;
552         }
553         if (event >= AUDIO_EVENT_MAX) {
554                 debug_error("invalid event : %d", event);
555                 return MM_ERROR_INVALID_ARGUMENT;
556         }
557
558         *event_name = g_events[event].name;
559         return MM_ERROR_NONE;
560 }
561
562 EXPORT_API
563 int mm_sound_dbus_get_method_name(audio_method_t method, const char **method_name)
564 {
565         if (!method_name) {
566                 debug_error("Invalid Parameter, method_name NULL");
567                 return MM_ERROR_INVALID_ARGUMENT;
568         }
569         if (method >= AUDIO_METHOD_MAX) {
570                 debug_error("invalid method : %d", method);
571                 return MM_ERROR_INVALID_ARGUMENT;
572         }
573
574         *method_name = g_methods[method].name;
575         return MM_ERROR_NONE;
576 }