e7f6419.patch 103 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495
  1. diff -Nuar a/libdleyna/server/async.c b/libdleyna/server/async.c
  2. --- a/libdleyna/server/async.c 2021-10-26 18:17:55.000000000 +0300
  3. +++ b/libdleyna/server/async.c 2022-06-02 23:36:05.000000000 +0300
  4. @@ -82,10 +82,6 @@
  5. {
  6. dls_async_task_t *cb_data = user_data;
  7. - if (cb_data->proxy != NULL)
  8. - gupnp_service_proxy_cancel_action(cb_data->proxy,
  9. - cb_data->action);
  10. -
  11. if (!cb_data->error)
  12. cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  13. DLEYNA_ERROR_CANCELLED,
  14. diff -Nuar a/libdleyna/server/device.c b/libdleyna/server/device.c
  15. --- a/libdleyna/server/device.c 2021-10-26 18:17:55.000000000 +0300
  16. +++ b/libdleyna/server/device.c 2022-06-02 23:36:05.000000000 +0300
  17. @@ -20,6 +20,8 @@
  18. *
  19. */
  20. +#include <config.h>
  21. +
  22. #include <string.h>
  23. #include <stdint.h>
  24. #include <stdio.h>
  25. @@ -45,7 +47,7 @@
  26. #include <libdleyna/core/core.h>
  27. #include <libdleyna/core/error.h>
  28. #include <libdleyna/core/log.h>
  29. -#include <libdleyna/core/service-task.h>
  30. +#include <libdleyna/core/gasync-task.h>
  31. #include "device.h"
  32. #include "interface.h"
  33. @@ -90,6 +92,7 @@
  34. struct dls_device_upload_t_ {
  35. SoupSession *soup_session;
  36. SoupMessage *msg;
  37. + GCancellable *cancellable;
  38. GMappedFile *mapped_file;
  39. gchar *body;
  40. gsize body_length;
  41. @@ -108,6 +111,7 @@
  42. typedef struct dls_device_download_t_ dls_device_download_t;
  43. struct dls_device_download_t_ {
  44. SoupSession *session;
  45. + GCancellable *cancellable;
  46. SoupMessage *msg;
  47. dls_async_task_t *task;
  48. };
  49. @@ -165,13 +169,12 @@
  50. static void prv_get_sr_token_for_props(GUPnPServiceProxy *proxy,
  51. const dls_device_t *device,
  52. dls_async_task_t *cb_data);
  53. -static void prv_browse_objects_end_action_cb(GUPnPServiceProxy *proxy,
  54. - GUPnPServiceProxyAction *action,
  55. +static void prv_browse_objects_end_action_cb(GObject *target,
  56. + GAsyncResult *res,
  57. gpointer user_data);
  58. -static GUPnPServiceProxyAction *prv_browse_objects_begin_action_cb(
  59. - dleyna_service_task_t *task,
  60. - GUPnPServiceProxy *proxy,
  61. - gboolean *failed);
  62. +static gboolean prv_browse_objects_begin_action_cb(
  63. + dleyna_gasync_task_t *task,
  64. + GObject *target);
  65. static void prv_get_sleeping_for_props(GUPnPServiceProxy *proxy,
  66. const dls_device_t *device,
  67. @@ -375,7 +378,7 @@
  68. g_variant_unref(dev->sort_ext_caps);
  69. g_variant_unref(dev->feature_list);
  70. g_free(dev->icon.mime_type);
  71. - g_free(dev->icon.bytes);
  72. + g_bytes_unref(dev->icon.bytes);
  73. g_free(dev);
  74. }
  75. }
  76. @@ -1232,49 +1235,52 @@
  77. g_error_free(error);
  78. }
  79. -static void prv_get_feature_list_cb(GUPnPServiceProxy *proxy,
  80. - GUPnPServiceProxyAction *action,
  81. +static void prv_get_feature_list_cb(GObject *source, GAsyncResult *res,
  82. gpointer user_data)
  83. {
  84. - gchar *result = NULL;
  85. - gboolean end;
  86. - GError *error = NULL;
  87. - prv_new_device_ct_t *priv_t = (prv_new_device_ct_t *)user_data;
  88. + g_autofree gchar *result = NULL;
  89. + g_autoptr(GError) error = NULL;
  90. + dleyna_gasync_task_t *task = user_data;
  91. + prv_new_device_ct_t *priv_t =
  92. + (prv_new_device_ct_t *) dleyna_gasync_task_get_user_data(task);
  93. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  94. +
  95. + action = gupnp_service_proxy_call_action_finish(
  96. + GUPNP_SERVICE_PROXY(source), res, &error);
  97. +
  98. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  99. + return;
  100. + }
  101. priv_t->dev->construct_step++;
  102. - end = gupnp_service_proxy_end_action(proxy, action, &error,
  103. + if (error == NULL) {
  104. + gupnp_service_proxy_action_get_result(action, &error,
  105. "FeatureList", G_TYPE_STRING,
  106. &result, NULL);
  107. + }
  108. - if (!end || (result == NULL)) {
  109. + if (error != NULL) {
  110. DLEYNA_LOG_WARNING("GetFeatureList operation failed: %s",
  111. - ((error != NULL) ? error->message
  112. - : "Invalid result"));
  113. - goto on_error;
  114. - }
  115. + error->message);
  116. + } else {
  117. + DLEYNA_LOG_DEBUG("GetFeatureList result: %s", result);
  118. - DLEYNA_LOG_DEBUG("GetFeatureList result: %s", result);
  119. + prv_get_feature_list_analyze(priv_t->dev, result);
  120. + }
  121. - prv_get_feature_list_analyze(priv_t->dev, result);
  122. + dleyna_task_queue_task_completed (((dleyna_task_atom_t *) task)->queue_id);
  123. +}
  124. -on_error:
  125. - if (error != NULL)
  126. - g_error_free(error);
  127. +static gboolean prv_get_feature_list(dleyna_gasync_task_t *task, GObject *proxy)
  128. +{
  129. + GUPnPServiceProxyAction *action =
  130. + gupnp_service_proxy_action_new("GetFeatureList", NULL);
  131. - g_free(result);
  132. -}
  133. + gupnp_service_proxy_call_action_async(
  134. + GUPNP_SERVICE_PROXY(proxy), action, dleyna_gasync_task_get_cancellable(task),
  135. + prv_get_feature_list_cb, task);
  136. -static GUPnPServiceProxyAction *prv_get_feature_list(
  137. - dleyna_service_task_t *task,
  138. - GUPnPServiceProxy *proxy,
  139. - gboolean *failed)
  140. -{
  141. - *failed = FALSE;
  142. -
  143. - return gupnp_service_proxy_begin_action(
  144. - proxy, "GetFeatureList",
  145. - dleyna_service_task_begin_action_cb,
  146. - task, NULL);
  147. + return FALSE;
  148. }
  149. static void prv_get_sort_ext_capabilities_analyze(dls_device_t *device,
  150. @@ -1310,51 +1316,56 @@
  151. #endif
  152. }
  153. -static void prv_get_sort_ext_capabilities_cb(GUPnPServiceProxy *proxy,
  154. - GUPnPServiceProxyAction *action,
  155. - gpointer user_data)
  156. +static void prv_get_sort_ext_capabilities_cb(GObject *source, GAsyncResult *res,
  157. + gpointer user_data)
  158. {
  159. - gchar *result = NULL;
  160. - gboolean end;
  161. - GError *error = NULL;
  162. - prv_new_device_ct_t *priv_t = (prv_new_device_ct_t *)user_data;
  163. + g_autofree gchar *result = NULL;
  164. + g_autoptr(GError) error = NULL;
  165. + dleyna_gasync_task_t *task = user_data;
  166. + prv_new_device_ct_t *priv_t =
  167. + (prv_new_device_ct_t *) dleyna_gasync_task_get_user_data(task);
  168. + g_autoptr(GUPnPServiceProxyAction) action;
  169. - priv_t->dev->construct_step++;
  170. - end = gupnp_service_proxy_end_action(proxy, action, &error,
  171. - "SortExtensionCaps",
  172. - G_TYPE_STRING, &result, NULL);
  173. + action = gupnp_service_proxy_call_action_finish(
  174. + GUPNP_SERVICE_PROXY(source), res, &error);
  175. - if (!end || (result == NULL)) {
  176. - DLEYNA_LOG_WARNING(
  177. - "GetSortExtensionCapabilities operation failed: %s",
  178. - ((error != NULL) ? error->message : "Invalid result"));
  179. - goto on_error;
  180. + g_print("Sort ext\n");
  181. +
  182. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  183. + return;
  184. }
  185. - DLEYNA_LOG_DEBUG("GetSortExtensionCapabilities result: %s", result);
  186. + priv_t->dev->construct_step++;
  187. - prv_get_sort_ext_capabilities_analyze(priv_t->dev, result);
  188. + if (error == NULL) {
  189. + gupnp_service_proxy_action_get_result(action, &error, "SortCaps",
  190. + G_TYPE_STRING, &result, NULL);
  191. + }
  192. -on_error:
  193. + if (error!= NULL) {
  194. + DLEYNA_LOG_WARNING("GetSortCapabilitiesExt operation failed: %s",
  195. + error->message);
  196. - if (error)
  197. - g_error_free(error);
  198. + } else {
  199. + DLEYNA_LOG_DEBUG("GetSortCapabilities result: %s", result);
  200. - g_free(result);
  201. + prv_get_sort_ext_capabilities_analyze(priv_t->dev, result);
  202. + }
  203. +
  204. + dleyna_task_queue_task_completed (((dleyna_task_atom_t *) task)->queue_id);
  205. }
  206. -static GUPnPServiceProxyAction *prv_get_sort_ext_capabilities(
  207. - dleyna_service_task_t *task,
  208. - GUPnPServiceProxy *proxy,
  209. - gboolean *failed)
  210. -{
  211. - *failed = FALSE;
  212. -
  213. - return gupnp_service_proxy_begin_action(
  214. - proxy,
  215. - "GetSortExtensionCapabilities",
  216. - dleyna_service_task_begin_action_cb,
  217. - task, NULL);
  218. +static gboolean prv_get_sort_ext_capabilities(dleyna_gasync_task_t *task,
  219. + GObject *target)
  220. +{
  221. + GUPnPServiceProxyAction *action =
  222. + gupnp_service_proxy_action_new("GetSortExtensionCapabilities", NULL);
  223. + gupnp_service_proxy_call_action_async(
  224. + GUPNP_SERVICE_PROXY(target), action,
  225. + dleyna_gasync_task_get_cancellable(task),
  226. + prv_get_sort_ext_capabilities_cb, task);
  227. +
  228. + return FALSE;
  229. }
  230. static void prv_get_capabilities_analyze(GHashTable *property_map,
  231. @@ -1405,117 +1416,125 @@
  232. #endif
  233. }
  234. -static void prv_get_sort_capabilities_cb(GUPnPServiceProxy *proxy,
  235. - GUPnPServiceProxyAction *action,
  236. +static void prv_get_sort_capabilities_cb(GObject *source,
  237. + GAsyncResult *res,
  238. gpointer user_data)
  239. {
  240. - gchar *result = NULL;
  241. - gboolean end;
  242. - GError *error = NULL;
  243. - prv_new_device_ct_t *priv_t = (prv_new_device_ct_t *)user_data;
  244. + g_autofree gchar *result = NULL;
  245. + g_autoptr(GError) error = NULL;
  246. + dleyna_gasync_task_t *task = user_data;
  247. + prv_new_device_ct_t *priv_t = (prv_new_device_ct_t *) dleyna_gasync_task_get_user_data(task);
  248. + g_autoptr(GUPnPServiceProxyAction) action;
  249. +
  250. + action = gupnp_service_proxy_call_action_finish(
  251. + GUPNP_SERVICE_PROXY(source), res, &error);
  252. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  253. + return;
  254. + }
  255. priv_t->dev->construct_step++;
  256. - end = gupnp_service_proxy_end_action(proxy, action, &error, "SortCaps",
  257. - G_TYPE_STRING, &result, NULL);
  258. - if (!end || (result == NULL)) {
  259. - DLEYNA_LOG_WARNING("GetSortCapabilities operation failed: %s",
  260. - ((error != NULL) ? error->message
  261. - : "Invalid result"));
  262. - goto on_error;
  263. + if (error == NULL) {
  264. + gupnp_service_proxy_action_get_result(action, &error, "SortCaps",
  265. + G_TYPE_STRING, &result, NULL);
  266. }
  267. - DLEYNA_LOG_DEBUG("GetSortCapabilities result: %s", result);
  268. -
  269. - prv_get_capabilities_analyze(priv_t->property_map, result,
  270. - &priv_t->dev->sort_caps);
  271. + if (error!= NULL) {
  272. + DLEYNA_LOG_WARNING("GetSortCapabilities operation failed: %s",
  273. + error->message);
  274. -on_error:
  275. + } else {
  276. + DLEYNA_LOG_DEBUG("GetSortCapabilities result: %s", result);
  277. - if (error)
  278. - g_error_free(error);
  279. + prv_get_capabilities_analyze(priv_t->property_map, result,
  280. + &priv_t->dev->sort_caps);
  281. + }
  282. - g_free(result);
  283. + dleyna_task_queue_task_completed (((dleyna_task_atom_t *) task)->queue_id);
  284. }
  285. -static GUPnPServiceProxyAction *prv_get_sort_capabilities(
  286. - dleyna_service_task_t *task,
  287. - GUPnPServiceProxy *proxy,
  288. - gboolean *failed)
  289. -{
  290. - *failed = FALSE;
  291. -
  292. - return gupnp_service_proxy_begin_action(
  293. - proxy,
  294. - "GetSortCapabilities",
  295. - dleyna_service_task_begin_action_cb,
  296. - task, NULL);
  297. +static gboolean prv_get_sort_capabilities(dleyna_gasync_task_t *task,
  298. + GObject *target)
  299. +{
  300. + GUPnPServiceProxyAction *action =
  301. + gupnp_service_proxy_action_new("GetSortCapabilities", NULL);
  302. + gupnp_service_proxy_call_action_async(
  303. + GUPNP_SERVICE_PROXY(target), action,
  304. + dleyna_gasync_task_get_cancellable(task),
  305. + prv_get_sort_capabilities_cb, task);
  306. +
  307. + return FALSE;
  308. }
  309. -static void prv_get_search_capabilities_cb(GUPnPServiceProxy *proxy,
  310. - GUPnPServiceProxyAction *action,
  311. +static void prv_get_search_capabilities_cb(GObject *source,
  312. + GAsyncResult *res,
  313. gpointer user_data)
  314. {
  315. - gchar *result = NULL;
  316. - gboolean end;
  317. - GError *error = NULL;
  318. - prv_new_device_ct_t *priv_t = (prv_new_device_ct_t *)user_data;
  319. + g_autofree gchar *result = NULL;
  320. + g_autoptr(GError) error = NULL;
  321. + dleyna_gasync_task_t *task = user_data;
  322. + prv_new_device_ct_t *priv_t =
  323. + (prv_new_device_ct_t *) dleyna_gasync_task_get_user_data(task);
  324. +
  325. + g_autoptr(GUPnPServiceProxyAction) action =
  326. + gupnp_service_proxy_call_action_finish(
  327. + GUPNP_SERVICE_PROXY(source), res, &error);
  328. +
  329. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  330. + return;
  331. + }
  332. +
  333. + if (error == NULL) {
  334. + gupnp_service_proxy_action_get_result(
  335. + action, &error, "SearchCaps", G_TYPE_STRING, &result,
  336. + NULL);
  337. + }
  338. priv_t->dev->construct_step++;
  339. - end = gupnp_service_proxy_end_action(proxy, action, &error,
  340. - "SearchCaps", G_TYPE_STRING,
  341. - &result, NULL);
  342. -
  343. - if (!end || (result == NULL)) {
  344. + if (error != NULL) {
  345. DLEYNA_LOG_WARNING("GetSearchCapabilities operation failed: %s",
  346. - ((error != NULL) ? error->message
  347. - : "Invalid result"));
  348. - goto on_error;
  349. - }
  350. + error->message);
  351. - DLEYNA_LOG_DEBUG("GetSearchCapabilities result: %s", result);
  352. + } else {
  353. + DLEYNA_LOG_DEBUG("GetSearchCapabilities result: %s", result);
  354. - prv_get_capabilities_analyze(priv_t->property_map, result,
  355. - &priv_t->dev->search_caps);
  356. + prv_get_capabilities_analyze(priv_t->property_map, result,
  357. + &priv_t->dev->search_caps);
  358. - if (g_hash_table_lookup(priv_t->property_map, "upnp:objectUpdateID"))
  359. - priv_t->dev->has_last_change = TRUE;
  360. + if(g_hash_table_lookup(priv_t->property_map,
  361. + "upnp:objectUpdateID"))
  362. + priv_t->dev->has_last_change = TRUE;
  363. + }
  364. -on_error:
  365. + dleyna_task_queue_task_completed (((dleyna_task_atom_t *) task)->queue_id);
  366. +}
  367. - if (error)
  368. - g_error_free(error);
  369. +static gboolean prv_get_search_capabilities(
  370. + dleyna_gasync_task_t *task,
  371. + GObject *target)
  372. +{
  373. + GUPnPServiceProxyAction *action =
  374. + gupnp_service_proxy_action_new("GetSearchCapabilities", NULL);
  375. - g_free(result);
  376. + gupnp_service_proxy_call_action_async(
  377. + GUPNP_SERVICE_PROXY(target), action, dleyna_gasync_task_get_cancellable(task),
  378. + prv_get_search_capabilities_cb, task);
  379. +
  380. + return FALSE;
  381. }
  382. -static GUPnPServiceProxyAction *prv_get_search_capabilities(
  383. - dleyna_service_task_t *task,
  384. - GUPnPServiceProxy *proxy,
  385. - gboolean *failed)
  386. -{
  387. - *failed = FALSE;
  388. -
  389. - return gupnp_service_proxy_begin_action(
  390. - proxy, "GetSearchCapabilities",
  391. - dleyna_service_task_begin_action_cb,
  392. - task, NULL);
  393. -}
  394. -
  395. -static GUPnPServiceProxyAction *prv_subscribe(dleyna_service_task_t *task,
  396. - GUPnPServiceProxy *proxy,
  397. - gboolean *failed)
  398. +static gboolean prv_subscribe(dleyna_gasync_task_t *task, GObject *target)
  399. {
  400. dls_device_t *device;
  401. - device = (dls_device_t *)dleyna_service_task_get_user_data(task);
  402. + device = (dls_device_t *)dleyna_gasync_task_get_user_data(task);
  403. device->construct_step++;
  404. dls_device_subscribe_to_service_changes(device);
  405. - *failed = FALSE;
  406. + dleyna_task_queue_task_completed (((dleyna_task_atom_t *) task)->queue_id);
  407. - return NULL;
  408. + return FALSE;
  409. }
  410. static gboolean prv_subtree_interface_filter(const gchar *object_path,
  411. @@ -1553,15 +1572,13 @@
  412. return retval;
  413. }
  414. -static GUPnPServiceProxyAction *prv_declare(dleyna_service_task_t *task,
  415. - GUPnPServiceProxy *proxy,
  416. - gboolean *failed)
  417. +static gboolean prv_declare(dleyna_gasync_task_t *task, GObject *target)
  418. {
  419. guint id;
  420. dls_device_t *device;
  421. prv_new_device_ct_t *priv_t;
  422. - priv_t = (prv_new_device_ct_t *)dleyna_service_task_get_user_data(task);
  423. + priv_t = (prv_new_device_ct_t *)dleyna_gasync_task_get_user_data(task);
  424. device = priv_t->dev;
  425. device->construct_step++;
  426. @@ -1588,9 +1605,9 @@
  427. DLEYNA_LOG_WARNING("dleyna_connector_publish_subtree FAILED");
  428. }
  429. - *failed = (!id);
  430. + dleyna_task_queue_task_completed (((dleyna_task_atom_t *) task)->queue_id);
  431. - return NULL;
  432. + return !id;
  433. }
  434. void dls_device_construct(
  435. @@ -1614,36 +1631,39 @@
  436. priv_t->property_map = property_map;
  437. s_proxy = context->cds.proxy;
  438. + GCancellable *cancellable = g_cancellable_new();
  439. if (dev->construct_step < 1)
  440. - dleyna_service_task_add(queue_id, prv_get_search_capabilities,
  441. - s_proxy,
  442. - prv_get_search_capabilities_cb, NULL,
  443. + dleyna_gasync_task_add(queue_id,
  444. + prv_get_search_capabilities,
  445. + G_OBJECT(s_proxy),
  446. + cancellable,
  447. + NULL,
  448. priv_t);
  449. if (dev->construct_step < 2)
  450. - dleyna_service_task_add(queue_id, prv_get_sort_capabilities,
  451. - s_proxy,
  452. - prv_get_sort_capabilities_cb, NULL,
  453. - priv_t);
  454. + dleyna_gasync_task_add(queue_id, prv_get_sort_capabilities,
  455. + G_OBJECT(s_proxy), cancellable, NULL,
  456. + priv_t);
  457. if (dev->construct_step < 3)
  458. - dleyna_service_task_add(queue_id, prv_get_sort_ext_capabilities,
  459. - s_proxy,
  460. - prv_get_sort_ext_capabilities_cb, NULL,
  461. + dleyna_gasync_task_add(queue_id, prv_get_sort_ext_capabilities,
  462. + G_OBJECT(s_proxy),
  463. + cancellable, NULL,
  464. priv_t);
  465. if (dev->construct_step < 4)
  466. - dleyna_service_task_add(queue_id, prv_get_feature_list, s_proxy,
  467. - prv_get_feature_list_cb, NULL, priv_t);
  468. + dleyna_gasync_task_add(queue_id, prv_get_feature_list,
  469. + G_OBJECT(s_proxy), cancellable, NULL,
  470. + priv_t);
  471. /* The following task should always be completed */
  472. - dleyna_service_task_add(queue_id, prv_subscribe, s_proxy,
  473. - NULL, NULL, dev);
  474. + dleyna_gasync_task_add(queue_id, prv_subscribe, G_OBJECT(s_proxy),
  475. + cancellable, NULL, dev);
  476. if (dev->construct_step < 6)
  477. - dleyna_service_task_add(queue_id, prv_declare, s_proxy,
  478. - NULL, g_free, priv_t);
  479. + dleyna_gasync_task_add(queue_id, prv_declare, G_OBJECT(s_proxy),
  480. + cancellable, g_free, priv_t);
  481. dleyna_task_queue_start(queue_id);
  482. }
  483. @@ -1885,32 +1905,35 @@
  484. cb_task_data->get_children_cb(cb_data);
  485. }
  486. -static void prv_get_children_cb(GUPnPServiceProxy *proxy,
  487. - GUPnPServiceProxyAction *action,
  488. - gpointer user_data)
  489. +static void prv_get_children_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  490. {
  491. - gchar *result = NULL;
  492. - const gchar *message;
  493. - gboolean end;
  494. - GUPnPDIDLLiteParser *parser = NULL;
  495. - GError *error = NULL;
  496. + g_autofree char *result = NULL;
  497. + g_autoptr(GUPnPDIDLLiteParser) parser = NULL;
  498. + g_autoptr(GError) error = NULL;
  499. dls_async_task_t *cb_data = user_data;
  500. dls_async_bas_t *cb_task_data = &cb_data->ut.bas;
  501. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  502. DLEYNA_LOG_DEBUG("Enter");
  503. - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  504. - &error, "Result",
  505. - G_TYPE_STRING, &result, NULL);
  506. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  507. + &error);
  508. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  509. + return;
  510. + }
  511. - if (!end || (result == NULL)) {
  512. - message = (error != NULL) ? error->message : "Invalid result";
  513. - DLEYNA_LOG_WARNING("Browse operation failed: %s", message);
  514. + if(error == NULL) {
  515. + gupnp_service_proxy_action_get_result(
  516. + action, &error, "Result", G_TYPE_STRING, &result, NULL);
  517. + }
  518. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  519. - DLEYNA_ERROR_OPERATION_FAILED,
  520. - "Browse operation failed: %s",
  521. - message);
  522. + if(error != NULL) {
  523. + DLEYNA_LOG_WARNING("Browse operation failed: %s",
  524. + error->message);
  525. +
  526. + cb_data->error = g_error_new(
  527. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  528. + "Browse operation failed: %s", error->message);
  529. goto on_error;
  530. }
  531. @@ -1949,18 +1972,8 @@
  532. on_error:
  533. (void) g_idle_add(dls_async_task_complete, cb_data);
  534. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  535. no_complete:
  536. -
  537. - if (error)
  538. - g_error_free(error);
  539. -
  540. - if (parser)
  541. - g_object_unref(parser);
  542. -
  543. - g_free(result);
  544. -
  545. DLEYNA_LOG_DEBUG("Exit");
  546. }
  547. @@ -1980,27 +1993,22 @@
  548. g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
  549. (gpointer *)&cb_data->proxy);
  550. - cb_data->action =
  551. - gupnp_service_proxy_begin_action(cb_data->proxy,
  552. - "Browse",
  553. - prv_get_children_cb,
  554. - cb_data,
  555. - "ObjectID", G_TYPE_STRING,
  556. - task->target.id,
  557. -
  558. - "BrowseFlag", G_TYPE_STRING,
  559. - "BrowseDirectChildren",
  560. -
  561. - "Filter", G_TYPE_STRING,
  562. - upnp_filter,
  563. -
  564. - "StartingIndex", G_TYPE_INT,
  565. - task->ut.get_children.start,
  566. - "RequestedCount", G_TYPE_INT,
  567. - task->ut.get_children.count,
  568. - "SortCriteria", G_TYPE_STRING,
  569. - sort_by,
  570. - NULL);
  571. + cb_data->action = gupnp_service_proxy_action_new(
  572. + "Browse", "ObjectID", G_TYPE_STRING, task->target.id,
  573. +
  574. + "BrowseFlag", G_TYPE_STRING, "BrowseDirectChildren",
  575. +
  576. + "Filter", G_TYPE_STRING, upnp_filter,
  577. +
  578. + "StartingIndex", G_TYPE_INT, task->ut.get_children.start,
  579. + "RequestedCount", G_TYPE_INT, task->ut.get_children.count,
  580. + "SortCriteria", G_TYPE_STRING, sort_by, NULL);
  581. +
  582. + gupnp_service_proxy_call_action_async(cb_data->proxy,
  583. + cb_data->action,
  584. + cb_data->cancellable,
  585. + prv_get_children_cb,
  586. + cb_data);
  587. cb_data->cancel_id = g_cancellable_connect(
  588. cb_data->cancellable,
  589. @@ -2142,32 +2150,34 @@
  590. return subscribed;
  591. }
  592. -static void prv_system_update_id_for_prop_cb(GUPnPServiceProxy *proxy,
  593. - GUPnPServiceProxyAction *action,
  594. - gpointer user_data)
  595. +static void prv_system_update_id_for_prop_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  596. {
  597. - GError *error = NULL;
  598. - const gchar *message;
  599. - gboolean end;
  600. + g_autoptr(GError) error = NULL;
  601. guint id = G_MAXUINT32;
  602. dls_async_task_t *cb_data = user_data;
  603. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  604. DLEYNA_LOG_DEBUG("Enter");
  605. - end = gupnp_service_proxy_end_action(proxy, action, &error,
  606. - "Id", G_TYPE_UINT, &id, NULL);
  607. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  608. + &error);
  609. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  610. + return;
  611. + }
  612. +
  613. + if(error == NULL) {
  614. + gupnp_service_proxy_action_get_result(action, &error, "Id",
  615. + G_TYPE_UINT, &id, NULL);
  616. + }
  617. - if (!end || (id == G_MAXUINT32)) {
  618. - message = (error != NULL) ? error->message : "Invalid result";
  619. + if(error != NULL) {
  620. DLEYNA_LOG_WARNING("Unable to retrieve SystemUpdateID: %s",
  621. - message);
  622. + error->message);
  623. cb_data->error = g_error_new(
  624. - DLEYNA_SERVER_ERROR,
  625. - DLEYNA_ERROR_OPERATION_FAILED,
  626. - "Unable to retrieve SystemUpdateID: %s",
  627. - message);
  628. -
  629. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  630. + "Unable to retrieve SystemUpdateID: %s",
  631. + error->message);
  632. goto on_complete;
  633. }
  634. @@ -2176,10 +2186,6 @@
  635. on_complete:
  636. (void) g_idle_add(dls_async_task_complete, cb_data);
  637. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  638. -
  639. - if (error)
  640. - g_error_free(error);
  641. DLEYNA_LOG_DEBUG("Exit");
  642. }
  643. @@ -2203,51 +2209,51 @@
  644. goto on_complete;
  645. }
  646. - cb_data->action = gupnp_service_proxy_begin_action(
  647. - proxy, "GetSystemUpdateID",
  648. - prv_system_update_id_for_prop_cb,
  649. - cb_data,
  650. - NULL);
  651. + cb_data->action = gupnp_service_proxy_action_new("GetSystemUpdateID", NULL);
  652. cb_data->proxy = proxy;
  653. g_object_add_weak_pointer((G_OBJECT(proxy)),
  654. (gpointer *)&cb_data->proxy);
  655. - cb_data->cancel_id = g_cancellable_connect(
  656. - cb_data->cancellable,
  657. - G_CALLBACK(dls_async_task_cancelled_cb),
  658. - cb_data, NULL);
  659. + gupnp_service_proxy_call_action_async(
  660. + proxy, cb_data->action, cb_data->cancellable,
  661. + prv_system_update_id_for_prop_cb, cb_data);
  662. on_complete:
  663. DLEYNA_LOG_DEBUG("Exit");
  664. }
  665. -static void prv_system_update_id_for_props_cb(GUPnPServiceProxy *proxy,
  666. - GUPnPServiceProxyAction *action,
  667. - gpointer user_data)
  668. +static void prv_system_update_id_for_props_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  669. {
  670. - GError *error = NULL;
  671. - const gchar *message;
  672. - gboolean end;
  673. + g_autoptr(GError) error = NULL;
  674. guint id = G_MAXUINT32;
  675. dls_async_task_t *cb_data = user_data;
  676. dls_async_get_all_t *cb_task_data = &cb_data->ut.get_all;
  677. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  678. +
  679. DLEYNA_LOG_DEBUG("Enter");
  680. - end = gupnp_service_proxy_end_action(proxy, action, &error,
  681. - "Id", G_TYPE_UINT, &id, NULL);
  682. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  683. + &error);
  684. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  685. + return;
  686. + }
  687. - if (!end || (id == G_MAXUINT32)) {
  688. - message = (error != NULL) ? error->message : "Invalid result";
  689. + if(error == NULL) {
  690. + gupnp_service_proxy_action_get_result(action, &error, "Id",
  691. + G_TYPE_UINT, &id, NULL);
  692. + }
  693. +
  694. + if(error != NULL) {
  695. DLEYNA_LOG_WARNING("Unable to retrieve SystemUpdateID: %s",
  696. - message);
  697. + error->message);
  698. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  699. - DLEYNA_ERROR_OPERATION_FAILED,
  700. - "Unable to retrieve SystemUpdateID: %s",
  701. - message);
  702. + cb_data->error = g_error_new(
  703. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  704. + "Unable to retrieve SystemUpdateID: %s",
  705. + error->message);
  706. goto on_complete;
  707. }
  708. @@ -2259,19 +2265,14 @@
  709. on_complete:
  710. if (!cb_data->error)
  711. - prv_get_sr_token_for_props(proxy, cb_data->task.target.device,
  712. + prv_get_sr_token_for_props(GUPNP_SERVICE_PROXY (source), cb_data->task.target.device,
  713. cb_data);
  714. else {
  715. cb_data->task.result = g_variant_ref_sink(g_variant_builder_end(
  716. cb_task_data->vb));
  717. (void) g_idle_add(dls_async_task_complete, cb_data);
  718. - g_cancellable_disconnect(cb_data->cancellable,
  719. - cb_data->cancel_id);
  720. }
  721. - if (error)
  722. - g_error_free(error);
  723. -
  724. DLEYNA_LOG_DEBUG("Exit");
  725. }
  726. @@ -2298,11 +2299,8 @@
  727. goto on_complete;
  728. }
  729. - cb_data->action = gupnp_service_proxy_begin_action(
  730. - proxy, "GetSystemUpdateID",
  731. - prv_system_update_id_for_props_cb,
  732. - cb_data,
  733. - NULL);
  734. + cb_data->action =
  735. + gupnp_service_proxy_action_new("GetSystemUpdateID", NULL);
  736. if (cb_data->proxy != NULL)
  737. g_object_remove_weak_pointer((G_OBJECT(cb_data->proxy)),
  738. @@ -2310,15 +2308,13 @@
  739. cb_data->proxy = proxy;
  740. + gupnp_service_proxy_call_action_async(
  741. + proxy, cb_data->action, cb_data->cancellable,
  742. + prv_system_update_id_for_props_cb, cb_data);
  743. +
  744. g_object_add_weak_pointer((G_OBJECT(proxy)),
  745. (gpointer *)&cb_data->proxy);
  746. - if (!cb_data->cancel_id)
  747. - cb_data->cancel_id = g_cancellable_connect(
  748. - cb_data->cancellable,
  749. - G_CALLBACK(dls_async_task_cancelled_cb),
  750. - cb_data, NULL);
  751. -
  752. on_complete:
  753. DLEYNA_LOG_DEBUG("Exit");
  754. @@ -2341,34 +2337,36 @@
  755. return subscribed;
  756. }
  757. -static void prv_sleeping_for_props_cb(GUPnPServiceProxy *proxy,
  758. - GUPnPServiceProxyAction *action,
  759. - gpointer user_data)
  760. +static void prv_sleeping_for_props_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  761. {
  762. - GError *error = NULL;
  763. - const gchar *message;
  764. - gchar *info = NULL;
  765. - gboolean end;
  766. + g_autoptr(GError) error = NULL;
  767. + g_autofree gchar *info = NULL;
  768. dls_async_task_t *cb_data = user_data;
  769. dls_async_get_all_t *cb_task_data;
  770. gboolean sleeping;
  771. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  772. DLEYNA_LOG_DEBUG("Enter");
  773. - end = gupnp_service_proxy_end_action(proxy, action, &error,
  774. - "NetworkInterfaceInfo",
  775. - G_TYPE_STRING,
  776. - &info, NULL);
  777. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  778. + &error);
  779. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  780. + return;
  781. + }
  782. - if (!end || (info == NULL)) {
  783. - message = (error != NULL) ? error->message : "Invalid result";
  784. + if(error == NULL) {
  785. + gupnp_service_proxy_action_get_result(
  786. + action, &error, "NetworkInterfaceInfo", G_TYPE_STRING,
  787. + &info, NULL);
  788. + }
  789. +
  790. + if (error != NULL) {
  791. DLEYNA_LOG_WARNING("NetworkInterfaceInfo retrieval failed: %s",
  792. - message);
  793. + error->message);
  794. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  795. - DLEYNA_ERROR_OPERATION_FAILED,
  796. - "GetInterfaceInfo failed: %s",
  797. - message);
  798. + cb_data->error = g_error_new(
  799. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  800. + "GetInterfaceInfo failed: %s", error->message);
  801. goto on_complete;
  802. }
  803. @@ -2384,15 +2382,9 @@
  804. cb_task_data->vb));
  805. }
  806. - g_free(info);
  807. -
  808. on_complete:
  809. (void) g_idle_add(dls_async_task_complete, cb_data);
  810. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  811. -
  812. - if (error)
  813. - g_error_free(error);
  814. DLEYNA_LOG_DEBUG("Exit");
  815. }
  816. @@ -2421,27 +2413,25 @@
  817. goto on_complete;
  818. }
  819. - cb_data->action = gupnp_service_proxy_begin_action(
  820. - proxy, "GetInterfaceInfo",
  821. - prv_sleeping_for_props_cb,
  822. - cb_data,
  823. - NULL);
  824. if (cb_data->proxy != NULL)
  825. g_object_remove_weak_pointer((G_OBJECT(cb_data->proxy)),
  826. (gpointer *)&cb_data->proxy);
  827. + cb_data->action = gupnp_service_proxy_action_new ("GetInterfaceInfo", NULL);
  828. +
  829. +
  830. +
  831. cb_data->proxy = proxy;
  832. g_object_add_weak_pointer((G_OBJECT(proxy)),
  833. (gpointer *)&cb_data->proxy);
  834. - if (!cb_data->cancel_id)
  835. - cb_data->cancel_id = g_cancellable_connect(
  836. - cb_data->cancellable,
  837. - G_CALLBACK(dls_async_task_cancelled_cb),
  838. - cb_data, NULL);
  839. -
  840. + gupnp_service_proxy_call_action_async(
  841. + proxy, cb_data->action,
  842. + cb_data->cancellable,
  843. + prv_sleeping_for_props_cb,
  844. + cb_data);
  845. return;
  846. on_complete:
  847. @@ -2476,31 +2466,34 @@
  848. return -1;
  849. }
  850. -static void prv_service_reset_for_prop_cb(GUPnPServiceProxy *proxy,
  851. - GUPnPServiceProxyAction *action,
  852. - gpointer user_data)
  853. +static void prv_service_reset_for_prop_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  854. {
  855. - GError *error = NULL;
  856. - const gchar *message;
  857. - gchar *token = NULL;
  858. - gboolean end;
  859. + g_autoptr(GError) error = NULL;
  860. + g_autofree gchar *token = NULL;
  861. dls_async_task_t *cb_data = user_data;
  862. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  863. DLEYNA_LOG_DEBUG("Enter");
  864. - end = gupnp_service_proxy_end_action(proxy, action, &error,
  865. - "ResetToken", G_TYPE_STRING,
  866. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  867. + &error);
  868. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  869. + return;
  870. + }
  871. +
  872. + if(error == NULL) {
  873. + gupnp_service_proxy_action_get_result(
  874. + action, &error,"ResetToken", G_TYPE_STRING,
  875. &token, NULL);
  876. + }
  877. - if (!end || (token == NULL)) {
  878. - message = (error != NULL) ? error->message : "Invalid result";
  879. + if (error != NULL) {
  880. DLEYNA_LOG_WARNING("Unable to retrieve ServiceResetToken: %s",
  881. - message);
  882. + error->message);
  883. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  884. - DLEYNA_ERROR_OPERATION_FAILED,
  885. - "GetServiceResetToken failed: %s",
  886. - message);
  887. + cb_data->error = g_error_new(
  888. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  889. + "GetServiceResetToken failed: %s", error->message);
  890. goto on_complete;
  891. }
  892. @@ -2509,15 +2502,9 @@
  893. DLEYNA_LOG_DEBUG("Service Reset %s", token);
  894. - g_free(token);
  895. -
  896. on_complete:
  897. (void) g_idle_add(dls_async_task_complete, cb_data);
  898. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  899. -
  900. - if (error)
  901. - g_error_free(error);
  902. DLEYNA_LOG_DEBUG("Exit");
  903. }
  904. @@ -2538,65 +2525,59 @@
  905. goto on_error;
  906. }
  907. - cb_data->action = gupnp_service_proxy_begin_action(
  908. - proxy, "GetServiceResetToken",
  909. - prv_service_reset_for_prop_cb,
  910. - cb_data,
  911. - NULL);
  912. cb_data->proxy = proxy;
  913. g_object_add_weak_pointer((G_OBJECT(proxy)),
  914. (gpointer *)&cb_data->proxy);
  915. - cb_data->cancel_id = g_cancellable_connect(
  916. - cb_data->cancellable,
  917. - G_CALLBACK(dls_async_task_cancelled_cb),
  918. - cb_data, NULL);
  919. + cb_data->action = gupnp_service_proxy_action_new("GetServiceResetToken", NULL);
  920. +
  921. + gupnp_service_proxy_call_action_async(
  922. + proxy, cb_data->action, cb_data->cancellable,
  923. + prv_service_reset_for_prop_cb, cb_data);
  924. on_error:
  925. DLEYNA_LOG_DEBUG("Exit");
  926. }
  927. -static void prv_service_reset_for_props_cb(GUPnPServiceProxy *proxy,
  928. - GUPnPServiceProxyAction *action,
  929. - gpointer user_data)
  930. +static void prv_service_reset_for_props_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  931. {
  932. - GError *error = NULL;
  933. - const gchar *message;
  934. - gchar *token = NULL;
  935. - gboolean end;
  936. + g_autoptr(GError) error = NULL;
  937. + g_autofree gchar *token = NULL;
  938. dls_async_task_t *cb_data = user_data;
  939. dls_async_get_all_t *cb_task_data;
  940. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  941. DLEYNA_LOG_DEBUG("Enter");
  942. cb_task_data = &cb_data->ut.get_all;
  943. - end = gupnp_service_proxy_end_action(proxy, action, &error,
  944. - "ResetToken", G_TYPE_STRING,
  945. - &token, NULL);
  946. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  947. + &error);
  948. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  949. + return;
  950. + }
  951. + if(error == NULL) {
  952. + gupnp_service_proxy_action_get_result(
  953. + action, &error,"ResetToken", G_TYPE_STRING,
  954. + &token, NULL);
  955. + }
  956. - if (!end || (token == NULL)) {
  957. - message = (error != NULL) ? error->message : "Invalid result";
  958. + if (error != NULL) {
  959. DLEYNA_LOG_WARNING("Unable to retrieve ServiceResetToken: %s",
  960. - message);
  961. + error->message);
  962. +
  963. + cb_data->error = g_error_new(
  964. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  965. + "GetServiceResetToken failed: %s", error->message);
  966. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  967. - DLEYNA_ERROR_OPERATION_FAILED,
  968. - "GetServiceResetToken failed: %s",
  969. - message);
  970. goto on_complete;
  971. }
  972. - g_variant_builder_add(cb_task_data->vb, "{sv}",
  973. - DLS_INTERFACE_PROP_SV_SERVICE_RESET_TOKEN,
  974. - g_variant_new_string(token));
  975. DLEYNA_LOG_DEBUG("Service Reset %s", token);
  976. - g_free(token);
  977. -
  978. on_complete:
  979. if ((!cb_data->error) && (cb_task_data->proxy))
  980. @@ -2608,13 +2589,8 @@
  981. cb_task_data->vb));
  982. (void) g_idle_add(dls_async_task_complete, cb_data);
  983. - g_cancellable_disconnect(cb_data->cancellable,
  984. - cb_data->cancel_id);
  985. }
  986. - if (error)
  987. - g_error_free(error);
  988. -
  989. DLEYNA_LOG_DEBUG("Exit");
  990. }
  991. @@ -2635,11 +2611,6 @@
  992. goto on_exit; /* No error here, just skip the property */
  993. }
  994. - cb_data->action = gupnp_service_proxy_begin_action(
  995. - proxy, "GetServiceResetToken",
  996. - prv_service_reset_for_props_cb,
  997. - cb_data,
  998. - NULL);
  999. if (cb_data->proxy != NULL)
  1000. g_object_remove_weak_pointer((G_OBJECT(cb_data->proxy)),
  1001. @@ -2649,11 +2620,10 @@
  1002. g_object_add_weak_pointer((G_OBJECT(proxy)),
  1003. (gpointer *)&cb_data->proxy);
  1004. - if (!cb_data->cancel_id)
  1005. - cb_data->cancel_id = g_cancellable_connect(
  1006. - cb_data->cancellable,
  1007. - G_CALLBACK(dls_async_task_cancelled_cb),
  1008. - cb_data, NULL);
  1009. + cb_data->action = gupnp_service_proxy_action_new("GetServiceResetToken", NULL);
  1010. + gupnp_service_proxy_call_action_async(
  1011. + proxy, cb_data->action, cb_data->cancellable,
  1012. + prv_service_reset_for_props_cb, cb_data);
  1013. on_exit:
  1014. @@ -2662,34 +2632,36 @@
  1015. return;
  1016. }
  1017. -static void prv_sleeping_for_prop_cb(GUPnPServiceProxy *proxy,
  1018. - GUPnPServiceProxyAction *action,
  1019. - gpointer user_data)
  1020. +static void prv_sleeping_for_prop_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  1021. {
  1022. - GError *error = NULL;
  1023. - const gchar *message;
  1024. - gchar *info = NULL;
  1025. - gboolean end;
  1026. + g_autoptr(GError) error = NULL;
  1027. + g_autofree gchar *info = NULL;
  1028. dls_async_task_t *cb_data = user_data;
  1029. gboolean sleeping;
  1030. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  1031. +
  1032. DLEYNA_LOG_DEBUG("Enter");
  1033. - end = gupnp_service_proxy_end_action(proxy, action, &error,
  1034. - "NetworkInterfaceInfo",
  1035. - G_TYPE_STRING,
  1036. - &info, NULL);
  1037. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  1038. + &error);
  1039. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  1040. + return;
  1041. + }
  1042. - if (!end || (info == NULL)) {
  1043. - message = (error != NULL) ? error->message : "Invalid result";
  1044. - DLEYNA_LOG_WARNING("NetworkInterfaceInfo retrieval failed: %s",
  1045. - message);
  1046. + if(error == NULL) {
  1047. + gupnp_service_proxy_action_get_result(
  1048. + action, &error, "NetworkInterfaceInfo", G_TYPE_STRING,
  1049. + &info, NULL);
  1050. + }
  1051. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  1052. - DLEYNA_ERROR_OPERATION_FAILED,
  1053. - "GetInterfaceInfo failed: %s",
  1054. - message);
  1055. + if (error != NULL) {
  1056. + DLEYNA_LOG_WARNING("NetworkInterfaceInfo retrieval failed: %s",
  1057. + error->message);
  1058. + cb_data->error = g_error_new(
  1059. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  1060. + "GetInterfaceInfo failed: %s", error->message);
  1061. goto on_complete;
  1062. }
  1063. @@ -2700,15 +2672,9 @@
  1064. g_variant_new_boolean(sleeping));
  1065. }
  1066. - g_free(info);
  1067. -
  1068. on_complete:
  1069. (void) g_idle_add(dls_async_task_complete, cb_data);
  1070. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  1071. -
  1072. - if (error)
  1073. - g_error_free(error);
  1074. DLEYNA_LOG_DEBUG("Exit");
  1075. }
  1076. @@ -2740,21 +2706,17 @@
  1077. goto on_complete;
  1078. }
  1079. - cb_data->action = gupnp_service_proxy_begin_action(
  1080. - proxy, "GetInterfaceInfo",
  1081. - prv_sleeping_for_prop_cb,
  1082. - cb_data,
  1083. - NULL);
  1084. -
  1085. cb_data->proxy = proxy;
  1086. g_object_add_weak_pointer((G_OBJECT(proxy)),
  1087. - (gpointer *)&cb_data->proxy);
  1088. + (gpointer *) &cb_data->proxy);
  1089. +
  1090. + cb_data->action =
  1091. + gupnp_service_proxy_action_new("GetInterfaceInfo", NULL);
  1092. + gupnp_service_proxy_call_action_async(
  1093. + proxy, cb_data->action, cb_data->cancellable,
  1094. + prv_sleeping_for_prop_cb, cb_data);
  1095. - cb_data->cancel_id = g_cancellable_connect(
  1096. - cb_data->cancellable,
  1097. - G_CALLBACK(dls_async_task_cancelled_cb),
  1098. - cb_data, NULL);
  1099. on_complete:
  1100. DLEYNA_LOG_DEBUG("Exit");
  1101. @@ -2777,32 +2739,35 @@
  1102. return !cb_task_data->device_object;
  1103. }
  1104. -static void prv_get_all_ms2spec_props_cb(GUPnPServiceProxy *proxy,
  1105. - GUPnPServiceProxyAction *action,
  1106. - gpointer user_data)
  1107. +static void prv_get_all_ms2spec_props_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  1108. {
  1109. - GError *error = NULL;
  1110. - const gchar *message;
  1111. - gchar *result = NULL;
  1112. - gboolean end;
  1113. - GUPnPDIDLLiteParser *parser = NULL;
  1114. + g_autoptr(GError) error = NULL;
  1115. + g_autofree gchar *result = NULL;
  1116. + g_autoptr(GUPnPDIDLLiteParser) parser = NULL;
  1117. dls_async_task_t *cb_data = user_data;
  1118. dls_async_get_all_t *cb_task_data = &cb_data->ut.get_all;
  1119. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  1120. DLEYNA_LOG_DEBUG("Enter");
  1121. - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  1122. - &error, "Result",
  1123. - G_TYPE_STRING, &result, NULL);
  1124. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  1125. + &error);
  1126. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  1127. + return;
  1128. + }
  1129. - if (!end || (result == NULL)) {
  1130. - message = (error != NULL) ? error->message : "Invalid result";
  1131. - DLEYNA_LOG_WARNING("Browse operation failed: %s", message);
  1132. + if(error == NULL) {
  1133. + gupnp_service_proxy_action_get_result(
  1134. + action, &error, "Result", G_TYPE_STRING, &result, NULL);
  1135. + }
  1136. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  1137. - DLEYNA_ERROR_OPERATION_FAILED,
  1138. - "Browse operation failed: %s",
  1139. - message);
  1140. + if(error != NULL) {
  1141. + DLEYNA_LOG_WARNING("Browse operation failed: %s",
  1142. + error->message);
  1143. +
  1144. + cb_data->error = g_error_new(
  1145. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  1146. + "Browse operation failed: %s", error->message);
  1147. goto on_error;
  1148. }
  1149. @@ -2847,7 +2812,7 @@
  1150. goto no_complete;
  1151. } else if (cb_data->task.type == DLS_TASK_GET_ALL_PROPS &&
  1152. cb_task_data->device_object) {
  1153. - prv_get_system_update_id_for_props(proxy,
  1154. + prv_get_system_update_id_for_props(GUPNP_SERVICE_PROXY(source),
  1155. cb_data->task.target.device,
  1156. cb_data);
  1157. @@ -2860,18 +2825,8 @@
  1158. on_error:
  1159. (void) g_idle_add(dls_async_task_complete, cb_data);
  1160. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  1161. no_complete:
  1162. -
  1163. - if (error)
  1164. - g_error_free(error);
  1165. -
  1166. - if (parser)
  1167. - g_object_unref(parser);
  1168. -
  1169. - g_free(result);
  1170. -
  1171. DLEYNA_LOG_DEBUG("Exit");
  1172. }
  1173. @@ -2904,27 +2859,22 @@
  1174. goto on_error;
  1175. }
  1176. - cb_data->action = gupnp_service_proxy_begin_action(
  1177. - context->cds.proxy, "Browse",
  1178. - prv_get_all_ms2spec_props_cb, cb_data,
  1179. - "ObjectID", G_TYPE_STRING, task->target.id,
  1180. - "BrowseFlag", G_TYPE_STRING, "BrowseMetadata",
  1181. - "Filter", G_TYPE_STRING, "*",
  1182. - "StartingIndex", G_TYPE_INT, 0,
  1183. - "RequestedCount", G_TYPE_INT, 0,
  1184. - "SortCriteria", G_TYPE_STRING,
  1185. - "", NULL);
  1186. + cb_data->action = gupnp_service_proxy_action_new(
  1187. + "Browse", "ObjectID", G_TYPE_STRING, task->target.id,
  1188. + "BrowseFlag", G_TYPE_STRING, "BrowseMetadata", "Filter",
  1189. + G_TYPE_STRING, "*", "StartingIndex", G_TYPE_INT, 0,
  1190. + "RequestedCount", G_TYPE_INT, 0, "SortCriteria", G_TYPE_STRING,
  1191. + "", NULL);
  1192. +
  1193. + gupnp_service_proxy_call_action_async(
  1194. + context->cds.proxy, cb_data->action, cb_data->cancellable,
  1195. + prv_get_all_ms2spec_props_cb, cb_data);
  1196. cb_data->proxy = context->cds.proxy;
  1197. g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
  1198. (gpointer *)&cb_data->proxy);
  1199. - cb_data->cancel_id = g_cancellable_connect(
  1200. - cb_data->cancellable,
  1201. - G_CALLBACK(dls_async_task_cancelled_cb),
  1202. - cb_data, NULL);
  1203. -
  1204. DLEYNA_LOG_DEBUG("Exit with SUCCESS");
  1205. return;
  1206. @@ -3096,33 +3046,34 @@
  1207. return TRUE;
  1208. }
  1209. -static void prv_count_children_cb(GUPnPServiceProxy *proxy,
  1210. - GUPnPServiceProxyAction *action,
  1211. - gpointer user_data)
  1212. -{
  1213. +static void prv_count_children_cb(GObject *source, GAsyncResult *res, gpointer user_data){
  1214. dls_device_count_data_t *count_data = user_data;
  1215. dls_async_task_t *cb_data = count_data->cb_data;
  1216. - GError *error = NULL;
  1217. - const gchar *message;
  1218. + g_autoptr(GError) error = NULL;
  1219. guint count = G_MAXUINT32;
  1220. gboolean complete = FALSE;
  1221. - gboolean end;
  1222. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  1223. DLEYNA_LOG_DEBUG("Enter");
  1224. - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  1225. - &error,
  1226. - "TotalMatches", G_TYPE_UINT, &count,
  1227. - NULL);
  1228. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  1229. + &error);
  1230. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  1231. + return;
  1232. + }
  1233. - if (!end || (count == G_MAXUINT32)) {
  1234. - message = (error != NULL) ? error->message : "Invalid result";
  1235. - DLEYNA_LOG_WARNING("Browse operation failed: %s", message);
  1236. + if(error == NULL) {
  1237. + gupnp_service_proxy_action_get_result(action, &error, "TotalMatches",
  1238. + G_TYPE_UINT, &count, NULL);
  1239. + }
  1240. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  1241. - DLEYNA_ERROR_OPERATION_FAILED,
  1242. - "Browse operation failed: %s",
  1243. - message);
  1244. + if(error != NULL) {
  1245. + DLEYNA_LOG_WARNING("Browse operation failed: %s",
  1246. + error->message);
  1247. +
  1248. + cb_data->error = g_error_new(
  1249. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  1250. + "Browse operation failed: %s", error->message);
  1251. goto on_error;
  1252. }
  1253. @@ -3134,13 +3085,8 @@
  1254. if (cb_data->error || complete) {
  1255. (void) g_idle_add(dls_async_task_complete, cb_data);
  1256. - g_cancellable_disconnect(cb_data->cancellable,
  1257. - cb_data->cancel_id);
  1258. }
  1259. - if (error)
  1260. - g_error_free(error);
  1261. -
  1262. DLEYNA_LOG_DEBUG("Exit");
  1263. }
  1264. @@ -3152,62 +3098,59 @@
  1265. DLEYNA_LOG_DEBUG("Enter");
  1266. prv_count_data_new(cb_data, cb, &count_data);
  1267. - cb_data->action =
  1268. - gupnp_service_proxy_begin_action(cb_data->proxy,
  1269. - "Browse",
  1270. - prv_count_children_cb,
  1271. - count_data,
  1272. - "ObjectID", G_TYPE_STRING, id,
  1273. -
  1274. - "BrowseFlag", G_TYPE_STRING,
  1275. - "BrowseDirectChildren",
  1276. + cb_data->action = gupnp_service_proxy_action_new(
  1277. + "Browse", "ObjectID", G_TYPE_STRING, id,
  1278. - "Filter", G_TYPE_STRING, "",
  1279. + "BrowseFlag", G_TYPE_STRING, "BrowseDirectChildren",
  1280. - "StartingIndex", G_TYPE_INT,
  1281. - 0,
  1282. + "Filter", G_TYPE_STRING, "",
  1283. - "RequestedCount", G_TYPE_INT,
  1284. - 1,
  1285. + "StartingIndex", G_TYPE_INT, 0,
  1286. - "SortCriteria", G_TYPE_STRING,
  1287. - "",
  1288. + "RequestedCount", G_TYPE_INT, 1,
  1289. - NULL);
  1290. + "SortCriteria", G_TYPE_STRING, "", NULL);
  1291. + gupnp_service_proxy_call_action_async(
  1292. + cb_data->proxy, cb_data->action, cb_data->cancellable,
  1293. + prv_count_children_cb, count_data);
  1294. DLEYNA_LOG_DEBUG("Exit with SUCCESS");
  1295. }
  1296. -static void prv_get_ms2spec_prop_cb(GUPnPServiceProxy *proxy,
  1297. - GUPnPServiceProxyAction *action,
  1298. - gpointer user_data)
  1299. +static void prv_get_ms2spec_prop_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  1300. {
  1301. - GError *error = NULL;
  1302. - const gchar *message;
  1303. - gchar *result = NULL;
  1304. - gboolean end;
  1305. - GUPnPDIDLLiteParser *parser = NULL;
  1306. + g_autoptr(GError) error = NULL;
  1307. + g_autofree gchar *result = NULL;
  1308. + g_autoptr(GUPnPDIDLLiteParser) parser = NULL;
  1309. dls_async_task_t *cb_data = user_data;
  1310. dls_async_get_prop_t *cb_task_data = &cb_data->ut.get_prop;
  1311. dls_task_get_prop_t *task_data = &cb_data->task.ut.get_prop;
  1312. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  1313. DLEYNA_LOG_DEBUG("Enter");
  1314. - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  1315. - &error, "Result",
  1316. - G_TYPE_STRING, &result, NULL);
  1317. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  1318. + &error);
  1319. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  1320. + return;
  1321. + }
  1322. - if (!end || (result == NULL)) {
  1323. - message = (error != NULL) ? error->message : "Invalid result";
  1324. - DLEYNA_LOG_WARNING("Browse operation failed: %s", message);
  1325. + if(error == NULL) {
  1326. + gupnp_service_proxy_action_get_result(
  1327. + action, &error, "Result", G_TYPE_STRING, &result, NULL);
  1328. + }
  1329. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  1330. - DLEYNA_ERROR_OPERATION_FAILED,
  1331. - "Browse operation failed: %s",
  1332. - message);
  1333. + if(error != NULL) {
  1334. + DLEYNA_LOG_WARNING("Browse operation failed: %s",
  1335. + error->message);
  1336. +
  1337. + cb_data->error = g_error_new(
  1338. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  1339. + "Browse operation failed: %s", error->message);
  1340. goto on_error;
  1341. }
  1342. +
  1343. DLEYNA_LOG_DEBUG("GetMS2SpecProp result: %s", result);
  1344. parser = gupnp_didl_lite_parser_new();
  1345. @@ -3257,18 +3200,8 @@
  1346. cb_data->task.target.id);
  1347. } else {
  1348. (void) g_idle_add(dls_async_task_complete, cb_data);
  1349. - g_cancellable_disconnect(cb_data->cancellable,
  1350. - cb_data->cancel_id);
  1351. }
  1352. - if (error)
  1353. - g_error_free(error);
  1354. -
  1355. - if (parser)
  1356. - g_object_unref(parser);
  1357. -
  1358. - g_free(result);
  1359. -
  1360. DLEYNA_LOG_DEBUG("Exit");
  1361. }
  1362. @@ -3319,24 +3252,16 @@
  1363. g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
  1364. (gpointer *)&cb_data->proxy);
  1365. - cb_data->action = gupnp_service_proxy_begin_action(
  1366. - cb_data->proxy, "Browse",
  1367. - prv_get_ms2spec_prop_cb,
  1368. - cb_data,
  1369. - "ObjectID", G_TYPE_STRING, cb_data->task.target.id,
  1370. - "BrowseFlag", G_TYPE_STRING,
  1371. - "BrowseMetadata",
  1372. - "Filter", G_TYPE_STRING, filter,
  1373. - "StartingIndex", G_TYPE_INT, 0,
  1374. - "RequestedCount", G_TYPE_INT, 0,
  1375. - "SortCriteria", G_TYPE_STRING,
  1376. - "",
  1377. - NULL);
  1378. -
  1379. - cb_data->cancel_id = g_cancellable_connect(
  1380. - cb_data->cancellable,
  1381. - G_CALLBACK(dls_async_task_cancelled_cb),
  1382. - cb_data, NULL);
  1383. + cb_data->action = gupnp_service_proxy_action_new(
  1384. + "Browse", "ObjectID", G_TYPE_STRING, cb_data->task.target.id,
  1385. + "BrowseFlag", G_TYPE_STRING, "BrowseMetadata", "Filter",
  1386. + G_TYPE_STRING, filter, "StartingIndex", G_TYPE_INT, 0,
  1387. + "RequestedCount", G_TYPE_INT, 0, "SortCriteria", G_TYPE_STRING,
  1388. + "", NULL);
  1389. +
  1390. + gupnp_service_proxy_call_action_async(cb_data->proxy, cb_data->action,
  1391. + cb_data->cancellable,
  1392. + prv_get_ms2spec_prop_cb, cb_data);
  1393. DLEYNA_LOG_DEBUG("Exit with SUCCESS");
  1394. @@ -3552,35 +3477,38 @@
  1395. DLEYNA_LOG_DEBUG("Exit with FAIL");
  1396. }
  1397. -static void prv_search_cb(GUPnPServiceProxy *proxy,
  1398. - GUPnPServiceProxyAction *action,
  1399. - gpointer user_data)
  1400. +static void prv_search_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  1401. {
  1402. - gchar *result = NULL;
  1403. - const gchar *message;
  1404. - gboolean end;
  1405. + g_autofree gchar *result = NULL;
  1406. guint count = G_MAXUINT32;
  1407. - GUPnPDIDLLiteParser *parser = NULL;
  1408. - GError *error = NULL;
  1409. + g_autoptr(GUPnPDIDLLiteParser) parser = NULL;
  1410. + g_autoptr(GError) error = NULL;
  1411. dls_async_task_t *cb_data = user_data;
  1412. dls_async_bas_t *cb_task_data = &cb_data->ut.bas;
  1413. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  1414. +
  1415. DLEYNA_LOG_DEBUG("Enter");
  1416. - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  1417. - &error,
  1418. - "Result", G_TYPE_STRING, &result,
  1419. - "TotalMatches", G_TYPE_UINT,
  1420. - &count, NULL);
  1421. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  1422. + &error);
  1423. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  1424. + return;
  1425. + }
  1426. - if (!end || (result == NULL) || (count == G_MAXUINT32)) {
  1427. - message = (error != NULL) ? error->message : "Invalid result";
  1428. - DLEYNA_LOG_WARNING("Search operation failed %s", message);
  1429. + if(error == NULL) {
  1430. + gupnp_service_proxy_action_get_result(
  1431. + action, &error, "Result", G_TYPE_STRING, &result,
  1432. + "TotalMatches", G_TYPE_UINT, &count, NULL);
  1433. + }
  1434. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  1435. - DLEYNA_ERROR_OPERATION_FAILED,
  1436. - "Search operation failed: %s",
  1437. - message);
  1438. + if(error != NULL) {
  1439. + DLEYNA_LOG_WARNING("Search operation failed: %s",
  1440. + error->message);
  1441. +
  1442. + cb_data->error = g_error_new(
  1443. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  1444. + "Search operation failed: %s", error->message);
  1445. goto on_error;
  1446. }
  1447. @@ -3628,18 +3556,9 @@
  1448. on_error:
  1449. (void) g_idle_add(dls_async_task_complete, cb_data);
  1450. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  1451. no_complete:
  1452. - if (parser)
  1453. - g_object_unref(parser);
  1454. -
  1455. - g_free(result);
  1456. -
  1457. - if (error)
  1458. - g_error_free(error);
  1459. -
  1460. DLEYNA_LOG_DEBUG("Exit");
  1461. }
  1462. @@ -3660,22 +3579,18 @@
  1463. g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
  1464. (gpointer *)&cb_data->proxy);
  1465. - cb_data->action = gupnp_service_proxy_begin_action(
  1466. - cb_data->proxy, "Search",
  1467. - prv_search_cb,
  1468. - cb_data,
  1469. - "ContainerID", G_TYPE_STRING, task->target.id,
  1470. - "SearchCriteria", G_TYPE_STRING, upnp_query,
  1471. - "Filter", G_TYPE_STRING, upnp_filter,
  1472. - "StartingIndex", G_TYPE_INT, task->ut.search.start,
  1473. - "RequestedCount", G_TYPE_INT, task->ut.search.count,
  1474. - "SortCriteria", G_TYPE_STRING, sort_by,
  1475. - NULL);
  1476. - cb_data->cancel_id = g_cancellable_connect(
  1477. - cb_data->cancellable,
  1478. - G_CALLBACK(dls_async_task_cancelled_cb),
  1479. - cb_data, NULL);
  1480. + cb_data->action = gupnp_service_proxy_action_new(
  1481. + "Search", "ContainerID", G_TYPE_STRING, task->target.id,
  1482. + "SearchCriteria", G_TYPE_STRING, upnp_query, "Filter",
  1483. + G_TYPE_STRING, upnp_filter, "StartingIndex", G_TYPE_INT,
  1484. + task->ut.search.start, "RequestedCount", G_TYPE_INT,
  1485. + task->ut.search.count, "SortCriteria", G_TYPE_STRING, sort_by,
  1486. + NULL);
  1487. +
  1488. + gupnp_service_proxy_call_action_async(cb_data->proxy, cb_data->action,
  1489. + cb_data->cancellable,
  1490. + prv_search_cb, cb_data);
  1491. DLEYNA_LOG_DEBUG("Exit");
  1492. }
  1493. @@ -3722,26 +3637,35 @@
  1494. g_variant_builder_add(bo->avb, "@a{sv}", gv_result);
  1495. }
  1496. -static void prv_get_child_count_end_action_cb(GUPnPServiceProxy *proxy,
  1497. - GUPnPServiceProxyAction *action,
  1498. +static void prv_get_child_count_end_action_cb(GObject *source,
  1499. + GAsyncResult *res,
  1500. gpointer user_data)
  1501. {
  1502. - GError *error = NULL;
  1503. - const gchar *message;
  1504. + g_autoptr(GError) error = NULL;
  1505. guint count = G_MAXUINT32;
  1506. - gboolean end;
  1507. + const char *message = NULL;
  1508. dls_async_browse_objects_t *cb_task_data;
  1509. - dls_async_task_t *cb_data = user_data;
  1510. + dls_async_task_t *cb_data = dleyna_gasync_task_get_user_data(user_data);
  1511. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  1512. DLEYNA_LOG_DEBUG("Enter");
  1513. - end = gupnp_service_proxy_end_action(proxy, action, &error,
  1514. - "TotalMatches", G_TYPE_UINT,
  1515. - &count, NULL);
  1516. + action = gupnp_service_proxy_call_action_finish(
  1517. + GUPNP_SERVICE_PROXY(source), res, &error);
  1518. - cb_task_data = &((dls_async_task_t *)user_data)->ut.browse_objects;
  1519. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  1520. + return;
  1521. + }
  1522. +
  1523. + if (error == NULL) {
  1524. + gupnp_service_proxy_action_get_result(action, &error,
  1525. + "TotalMatches", G_TYPE_UINT,
  1526. + &count, NULL);
  1527. + }
  1528. - if (!end || (count == G_MAXUINT32)) {
  1529. + cb_task_data = &(cb_data)->ut.browse_objects;
  1530. +
  1531. + if (error != NULL || count == G_MAXUINT32) {
  1532. message = (error != NULL) ? error->message : "Invalid result";
  1533. DLEYNA_LOG_WARNING("Browse operation failed: %s", message);
  1534. @@ -3777,34 +3701,29 @@
  1535. }
  1536. if (cb_task_data->index < cb_task_data->object_count)
  1537. - dleyna_service_task_add(cb_task_data->queue_id,
  1538. - prv_browse_objects_begin_action_cb,
  1539. - proxy,
  1540. - prv_browse_objects_end_action_cb,
  1541. - NULL, user_data);
  1542. -
  1543. - if (error)
  1544. - g_error_free(error);
  1545. + dleyna_gasync_task_add(
  1546. + cb_task_data->queue_id,
  1547. + prv_browse_objects_begin_action_cb, source,
  1548. + dleyna_gasync_task_get_user_data(user_data), NULL,
  1549. + cb_data);
  1550. DLEYNA_LOG_DEBUG("Exit");
  1551. }
  1552. -static GUPnPServiceProxyAction *prv_get_child_count_begin_action_cb(
  1553. - dleyna_service_task_t *task,
  1554. - GUPnPServiceProxy *proxy,
  1555. - gboolean *failed)
  1556. +static gboolean prv_get_child_count_begin_action_cb(dleyna_gasync_task_t *task,
  1557. + GObject *target)
  1558. {
  1559. GUPnPServiceProxyAction *action;
  1560. dls_task_t *user_data;
  1561. const gchar *path;
  1562. - gchar *root_path = NULL;
  1563. - gchar *id = NULL;
  1564. + g_autofree gchar *root_path = NULL;
  1565. + g_autofree gchar *id = NULL;
  1566. dls_async_browse_objects_t *cb_task_data;
  1567. - GError *error = NULL;
  1568. + g_autoptr(GError) error = NULL;
  1569. DLEYNA_LOG_DEBUG("Enter");
  1570. - user_data = (dls_task_t *)dleyna_service_task_get_user_data(task);
  1571. + user_data = (dls_task_t *)dleyna_gasync_task_get_user_data(task);
  1572. cb_task_data = &((dls_async_task_t *)user_data)->ut.browse_objects;
  1573. path = cb_task_data->objects_id[cb_task_data->index - 1];
  1574. @@ -3814,9 +3733,7 @@
  1575. if (error != NULL)
  1576. goto exit;
  1577. - action = gupnp_service_proxy_begin_action(
  1578. - proxy, "Browse",
  1579. - dleyna_service_task_begin_action_cb, task,
  1580. + action = gupnp_service_proxy_action_new ("Browse",
  1581. "ObjectID", G_TYPE_STRING, id,
  1582. "BrowseFlag", G_TYPE_STRING, "BrowseDirectChildren",
  1583. "Filter", G_TYPE_STRING, "",
  1584. @@ -3825,12 +3742,12 @@
  1585. "SortCriteria", G_TYPE_STRING, "",
  1586. NULL);
  1587. - g_free(root_path);
  1588. - g_free(id);
  1589. + gupnp_service_proxy_call_action_async(
  1590. + GUPNP_SERVICE_PROXY(target), action,
  1591. + dleyna_gasync_task_get_cancellable(task),
  1592. + prv_get_child_count_end_action_cb, task);
  1593. exit:
  1594. - *failed = FALSE;
  1595. -
  1596. if (error != NULL) {
  1597. DLEYNA_LOG_WARNING("%s: %s", path, error->message);
  1598. action = NULL;
  1599. @@ -3843,46 +3760,51 @@
  1600. }
  1601. if (cb_task_data->index < cb_task_data->object_count)
  1602. - dleyna_service_task_add(
  1603. + dleyna_gasync_task_add(
  1604. cb_task_data->queue_id,
  1605. prv_browse_objects_begin_action_cb,
  1606. - proxy,
  1607. - prv_browse_objects_end_action_cb,
  1608. + target,
  1609. + dleyna_gasync_task_get_cancellable(task),
  1610. NULL, user_data);
  1611. - g_error_free(error);
  1612. }
  1613. - return action;
  1614. + return FALSE;
  1615. }
  1616. -static void prv_browse_objects_end_action_cb(GUPnPServiceProxy *proxy,
  1617. - GUPnPServiceProxyAction *action,
  1618. +static void prv_browse_objects_end_action_cb(GObject *source,
  1619. + GAsyncResult *res,
  1620. gpointer user_data)
  1621. {
  1622. GError *error = NULL;
  1623. - dls_async_task_t *cb_data = user_data;
  1624. + dleyna_gasync_task_t *task = user_data;
  1625. + dls_async_task_t *cb_data = dleyna_gasync_task_get_user_data(task);
  1626. dls_async_browse_objects_t *cb_task_data = &cb_data->ut.browse_objects;
  1627. dls_async_get_all_t *cb_all_data = &cb_data->ut.browse_objects.get_all;
  1628. GUPnPDIDLLiteParser *parser = NULL;
  1629. gchar *result = NULL;
  1630. - const gchar *message;
  1631. - gboolean end;
  1632. DLEYNA_LOG_DEBUG("Enter");
  1633. - end = gupnp_service_proxy_end_action(proxy, action, &error,
  1634. - "Result", G_TYPE_STRING, &result,
  1635. - NULL);
  1636. + g_autoptr(GUPnPServiceProxyAction) action;
  1637. - if (!end || (result == NULL)) {
  1638. - message = (error != NULL) ? error->message : "Invalid result";
  1639. + action = gupnp_service_proxy_call_action_finish(
  1640. + GUPNP_SERVICE_PROXY(source), res, &error);
  1641. +
  1642. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  1643. + return;
  1644. + }
  1645. +
  1646. + gupnp_service_proxy_action_get_result(action, &error, "Result",
  1647. + G_TYPE_STRING, &result, NULL);
  1648. +
  1649. + if (error != NULL) {
  1650. DLEYNA_LOG_WARNING("Browse Object operation failed: %s",
  1651. - message);
  1652. + error->message);
  1653. cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  1654. DLEYNA_ERROR_OPERATION_FAILED,
  1655. "Browse operation failed: %s",
  1656. - message);
  1657. + error->message);
  1658. goto on_exit;
  1659. }
  1660. @@ -3924,11 +3846,11 @@
  1661. if (cb_all_data->need_child_count &&
  1662. (cb_all_data->filter_mask & DLS_UPNP_MASK_PROP_CHILD_COUNT)) {
  1663. DLEYNA_LOG_DEBUG("Need Child Count");
  1664. - dleyna_service_task_add(cb_task_data->queue_id,
  1665. - prv_get_child_count_begin_action_cb,
  1666. - cb_data->proxy,
  1667. - prv_get_child_count_end_action_cb,
  1668. - NULL, cb_data);
  1669. + dleyna_gasync_task_add(cb_task_data->queue_id,
  1670. + prv_get_child_count_begin_action_cb,
  1671. + G_OBJECT(cb_data->proxy),
  1672. + dleyna_gasync_task_get_cancellable(task),
  1673. + NULL, cb_data);
  1674. goto no_complete;
  1675. }
  1676. @@ -3938,7 +3860,7 @@
  1677. on_exit:
  1678. if (cb_data->error != NULL) {
  1679. - message = cb_task_data->objects_id[cb_task_data->index - 1];
  1680. + const char *message = cb_task_data->objects_id[cb_task_data->index - 1];
  1681. prv_browse_objects_add_error_result(cb_task_data, message,
  1682. cb_data->error);
  1683. g_error_free(cb_data->error);
  1684. @@ -3951,11 +3873,11 @@
  1685. }
  1686. if (cb_task_data->index < cb_task_data->object_count)
  1687. - dleyna_service_task_add(cb_task_data->queue_id,
  1688. - prv_browse_objects_begin_action_cb,
  1689. - cb_data->proxy,
  1690. - prv_browse_objects_end_action_cb,
  1691. - NULL, cb_data);
  1692. + dleyna_gasync_task_add(cb_task_data->queue_id,
  1693. + prv_browse_objects_begin_action_cb,
  1694. + G_OBJECT(cb_data->proxy),
  1695. + dleyna_gasync_task_get_cancellable(task),
  1696. + NULL, cb_data);
  1697. no_complete:
  1698. if (parser)
  1699. @@ -3969,10 +3891,8 @@
  1700. DLEYNA_LOG_DEBUG("Exit");
  1701. }
  1702. -static GUPnPServiceProxyAction *prv_browse_objects_begin_action_cb(
  1703. - dleyna_service_task_t *task,
  1704. - GUPnPServiceProxy *proxy,
  1705. - gboolean *failed)
  1706. +static gboolean prv_browse_objects_begin_action_cb(dleyna_gasync_task_t *task,
  1707. + GObject *target)
  1708. {
  1709. GUPnPServiceProxyAction *action;
  1710. dls_task_t *user_data;
  1711. @@ -3984,7 +3904,7 @@
  1712. DLEYNA_LOG_DEBUG("Enter called");
  1713. - user_data = (dls_task_t *)dleyna_service_task_get_user_data(task);
  1714. + user_data = (dls_task_t *)dleyna_gasync_task_get_user_data(task);
  1715. cb_task_data = &((dls_async_task_t *)user_data)->ut.browse_objects;
  1716. path = cb_task_data->objects_id[cb_task_data->index];
  1717. @@ -3999,22 +3919,22 @@
  1718. DLEYNA_LOG_DEBUG("Browse Metadata for path [id]: %s [%s]", path, id);
  1719. - action = gupnp_service_proxy_begin_action(
  1720. - proxy, "Browse",
  1721. - dleyna_service_task_begin_action_cb, task,
  1722. - "ObjectID", G_TYPE_STRING, id,
  1723. - "BrowseFlag", G_TYPE_STRING, "BrowseMetadata",
  1724. - "Filter", G_TYPE_STRING, cb_task_data->upnp_filter,
  1725. - "StartingIndex", G_TYPE_INT, 0,
  1726. - "RequestedCount", G_TYPE_INT, 0,
  1727. - "SortCriteria", G_TYPE_STRING, "", NULL);
  1728. + action = gupnp_service_proxy_action_new(
  1729. + "Browse", "ObjectID", G_TYPE_STRING, id, "BrowseFlag",
  1730. + G_TYPE_STRING, "BrowseMetadata", "Filter", G_TYPE_STRING,
  1731. + cb_task_data->upnp_filter, "StartingIndex", G_TYPE_INT, 0,
  1732. + "RequestedCount", G_TYPE_INT, 0, "SortCriteria", G_TYPE_STRING,
  1733. + "", NULL);
  1734. +
  1735. + gupnp_service_proxy_call_action_async(
  1736. + GUPNP_SERVICE_PROXY(target), action,
  1737. + dleyna_gasync_task_get_cancellable(task),
  1738. + prv_browse_objects_end_action_cb, task);
  1739. g_free(root_path);
  1740. g_free(id);
  1741. exit:
  1742. - *failed = FALSE;
  1743. -
  1744. /* It's the ONLY place where index is incremented */
  1745. cb_task_data->index++;
  1746. @@ -4026,28 +3946,14 @@
  1747. g_error_free(error);
  1748. if (cb_task_data->index < cb_task_data->object_count)
  1749. - dleyna_service_task_add(
  1750. - cb_task_data->queue_id,
  1751. - prv_browse_objects_begin_action_cb,
  1752. - proxy,
  1753. - prv_browse_objects_end_action_cb,
  1754. - NULL, user_data);
  1755. + dleyna_gasync_task_add(
  1756. + cb_task_data->queue_id,
  1757. + prv_browse_objects_begin_action_cb, target,
  1758. + dleyna_gasync_task_get_cancellable(task), NULL,
  1759. + user_data);
  1760. }
  1761. - return action;
  1762. -}
  1763. -
  1764. -static void prv_browse_objects_chain_cancelled(GCancellable *cancellable,
  1765. - gpointer user_data)
  1766. -{
  1767. - dls_async_task_t *cb_data = user_data;
  1768. -
  1769. - DLEYNA_LOG_DEBUG("Enter");
  1770. -
  1771. - dleyna_task_processor_cancel_queue(cb_data->ut.browse_objects.queue_id);
  1772. - dls_async_task_cancelled_cb(cancellable, user_data);
  1773. -
  1774. - DLEYNA_LOG_DEBUG("Exit");
  1775. + return FALSE;
  1776. }
  1777. static void prv_browse_objects_chain_end(gboolean cancelled, gpointer data)
  1778. @@ -4108,12 +4014,12 @@
  1779. queue_id = dleyna_task_processor_add_queue(
  1780. dls_server_get_task_processor(),
  1781. - dleyna_service_task_create_source(),
  1782. + dleyna_gasync_task_create_source(),
  1783. DLS_SERVER_SINK,
  1784. DLEYNA_TASK_QUEUE_FLAG_AUTO_REMOVE,
  1785. - dleyna_service_task_process_cb,
  1786. - dleyna_service_task_cancel_cb,
  1787. - dleyna_service_task_delete_cb);
  1788. + dleyna_gasync_task_process_cb,
  1789. + dleyna_gasync_task_cancel_cb,
  1790. + dleyna_gasync_task_delete_cb);
  1791. dleyna_task_queue_set_finally(queue_id, prv_browse_objects_chain_end);
  1792. dleyna_task_queue_set_user_data(queue_id, task);
  1793. @@ -4130,16 +4036,9 @@
  1794. g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
  1795. (gpointer *)&cb_data->proxy);
  1796. - cb_data->cancel_id = g_cancellable_connect(
  1797. - cb_data->cancellable,
  1798. - G_CALLBACK(prv_browse_objects_chain_cancelled),
  1799. - cb_data, NULL);
  1800. -
  1801. - dleyna_service_task_add(queue_id,
  1802. - prv_browse_objects_begin_action_cb,
  1803. - cb_data->proxy,
  1804. - prv_browse_objects_end_action_cb,
  1805. - NULL, cb_data);
  1806. + dleyna_gasync_task_add(queue_id, prv_browse_objects_begin_action_cb,
  1807. + G_OBJECT(cb_data->proxy), cb_data->cancellable, NULL,
  1808. + cb_data);
  1809. dleyna_task_queue_start(queue_id);
  1810. @@ -4170,21 +4069,15 @@
  1811. g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
  1812. (gpointer *)&cb_data->proxy);
  1813. - cb_data->action = gupnp_service_proxy_begin_action(
  1814. - cb_data->proxy, "Browse",
  1815. - prv_get_all_ms2spec_props_cb, cb_data,
  1816. - "ObjectID", G_TYPE_STRING, task->target.id,
  1817. - "BrowseFlag", G_TYPE_STRING, "BrowseMetadata",
  1818. - "Filter", G_TYPE_STRING, upnp_filter,
  1819. - "StartingIndex", G_TYPE_INT, 0,
  1820. - "RequestedCount", G_TYPE_INT, 0,
  1821. - "SortCriteria", G_TYPE_STRING,
  1822. - "", NULL);
  1823. -
  1824. - cb_data->cancel_id = g_cancellable_connect(
  1825. - cb_data->cancellable,
  1826. - G_CALLBACK(dls_async_task_cancelled_cb),
  1827. - cb_data, NULL);
  1828. + cb_data->action = gupnp_service_proxy_action_new(
  1829. + "Browse", "ObjectID", G_TYPE_STRING, task->target.id,
  1830. + "BrowseFlag", G_TYPE_STRING, "BrowseMetadata", "Filter",
  1831. + G_TYPE_STRING, upnp_filter, "StartingIndex", G_TYPE_INT, 0,
  1832. + "RequestedCount", G_TYPE_INT, 0, "SortCriteria", G_TYPE_STRING,
  1833. + "", NULL);
  1834. + gupnp_service_proxy_call_action_async(
  1835. + cb_data->proxy, cb_data->action, cb_data->cancellable,
  1836. + prv_get_all_ms2spec_props_cb, cb_data);
  1837. DLEYNA_LOG_DEBUG("Exit");
  1838. }
  1839. @@ -4373,18 +4266,15 @@
  1840. }
  1841. }
  1842. -static void prv_upload_delete_cb(GUPnPServiceProxy *proxy,
  1843. - GUPnPServiceProxyAction *action,
  1844. - gpointer user_data)
  1845. +static void prv_upload_delete_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  1846. {
  1847. dls_async_task_t *cb_data = user_data;
  1848. DLEYNA_LOG_DEBUG("Enter");
  1849. - (void) gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  1850. - NULL, NULL);
  1851. + gupnp_service_proxy_call_action_finish(cb_data->proxy, res, NULL);
  1852. +
  1853. (void) g_idle_add(dls_async_task_complete, cb_data);
  1854. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  1855. DLEYNA_LOG_DEBUG("Exit");
  1856. }
  1857. @@ -4447,18 +4337,25 @@
  1858. NULL);
  1859. }
  1860. -static void prv_post_finished(SoupSession *session, SoupMessage *msg,
  1861. +static void prv_post_finished(GObject *source, GAsyncResult *res,
  1862. gpointer user_data)
  1863. {
  1864. dls_device_upload_job_t *upload_job = user_data;
  1865. dls_device_upload_t *upload;
  1866. gint *upload_id;
  1867. + g_autoptr(GError) error = NULL;
  1868. + g_autoptr(GBytes) data = NULL;
  1869. + SoupMessage *msg = soup_session_get_async_result_message(
  1870. + SOUP_SESSION(source), res);
  1871. DLEYNA_LOG_DEBUG("Enter");
  1872. DLEYNA_LOG_DEBUG("Upload %u finished. Code %u Message %s",
  1873. - upload_job->upload_id, msg->status_code,
  1874. - msg->reason_phrase);
  1875. + upload_job->upload_id, soup_message_get_status(msg),
  1876. + soup_message_get_reason_phrase (msg));
  1877. +
  1878. + data = soup_session_send_and_read_finish(SOUP_SESSION(source), res,
  1879. + &error);
  1880. /* This is clumsy but we need to distinguish between two cases:
  1881. 1. We cancel because the process is exitting.
  1882. @@ -4481,22 +4378,27 @@
  1883. &upload_job->upload_id);
  1884. if (upload) {
  1885. upload_job->remove_idle =
  1886. - g_timeout_add(30000, prv_remove_update_job, user_data);
  1887. + g_timeout_add_seconds(30, prv_remove_update_job, user_data);
  1888. - if (SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) {
  1889. - upload->status = DLS_UPLOAD_STATUS_COMPLETED;
  1890. - upload->bytes_uploaded = upload->bytes_to_upload;
  1891. - } else if (msg->status_code == SOUP_STATUS_CANCELLED) {
  1892. + // FIXME...
  1893. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  1894. upload->status = DLS_UPLOAD_STATUS_CANCELLED;
  1895. } else {
  1896. - upload->status = DLS_UPLOAD_STATUS_ERROR;
  1897. + SoupStatus status =
  1898. + soup_message_get_status(upload->msg);
  1899. + if(SOUP_STATUS_IS_SUCCESSFUL(status)) {
  1900. + upload->status = DLS_UPLOAD_STATUS_COMPLETED;
  1901. + upload->bytes_uploaded =
  1902. + upload->bytes_to_upload;
  1903. + } else {
  1904. + upload->status = DLS_UPLOAD_STATUS_ERROR;
  1905. + }
  1906. }
  1907. DLEYNA_LOG_DEBUG("Upload Status: %s", upload->status);
  1908. prv_generate_upload_update(upload_job, upload);
  1909. - g_object_unref(upload->msg);
  1910. upload->msg = NULL;
  1911. g_object_unref(upload->soup_session);
  1912. @@ -4532,10 +4434,9 @@
  1913. if (upload) {
  1914. if (upload->msg) {
  1915. - soup_session_cancel_message(upload->soup_session,
  1916. - upload->msg,
  1917. - SOUP_STATUS_CANCELLED);
  1918. + g_cancellable_cancel(upload->cancellable);
  1919. g_object_unref(upload->msg);
  1920. + g_object_unref(upload->cancellable);
  1921. }
  1922. if (upload->soup_session)
  1923. @@ -4552,12 +4453,12 @@
  1924. DLEYNA_LOG_DEBUG("Exit");
  1925. }
  1926. -static void prv_post_bytes_written(SoupMessage *msg, SoupBuffer *chunk,
  1927. +static void prv_post_bytes_written(SoupMessage *msg, guint chunk_size,
  1928. gpointer user_data)
  1929. {
  1930. dls_device_upload_t *upload = user_data;
  1931. - upload->bytes_uploaded += chunk->length;
  1932. + upload->bytes_uploaded += chunk_size;
  1933. if (upload->bytes_uploaded > upload->bytes_to_upload)
  1934. upload->bytes_uploaded = upload->bytes_to_upload;
  1935. }
  1936. @@ -4596,6 +4497,7 @@
  1937. upload = g_new0(dls_device_upload_t, 1);
  1938. upload->soup_session = soup_session_new();
  1939. + upload->cancellable = g_cancellable_new();
  1940. upload->msg = soup_message_new("POST", import_uri);
  1941. upload->mapped_file = mapped_file;
  1942. upload->body = body;
  1943. @@ -4613,11 +4515,15 @@
  1944. upload->status = DLS_UPLOAD_STATUS_IN_PROGRESS;
  1945. upload->bytes_to_upload = up_body_length;
  1946. - soup_message_headers_set_expectations(upload->msg->request_headers,
  1947. + SoupMessageHeaders *headers =
  1948. + soup_message_get_request_headers(upload->msg);
  1949. + soup_message_headers_set_expectations(headers,
  1950. SOUP_EXPECTATION_CONTINUE);
  1951. - soup_message_set_request(upload->msg, mime_type, SOUP_MEMORY_STATIC,
  1952. - up_body, up_body_length);
  1953. + GInputStream *is = g_memory_input_stream_new_from_data(
  1954. + up_body, up_body_length, NULL);
  1955. + soup_message_set_request_body(upload->msg, mime_type, is,
  1956. + up_body_length);
  1957. g_signal_connect(upload->msg, "wrote-body-data",
  1958. G_CALLBACK(prv_post_bytes_written), upload);
  1959. @@ -4634,35 +4540,36 @@
  1960. return NULL;
  1961. }
  1962. -static void prv_create_container_cb(GUPnPServiceProxy *proxy,
  1963. - GUPnPServiceProxyAction *action,
  1964. - gpointer user_data)
  1965. +static void prv_create_container_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  1966. {
  1967. dls_async_task_t *cb_data = user_data;
  1968. - const gchar *message;
  1969. - GError *error = NULL;
  1970. - gchar *result = NULL;
  1971. - gchar *object_id = NULL;
  1972. - gchar *object_path;
  1973. - gboolean end;
  1974. + g_autoptr(GError) error = NULL;
  1975. + g_autofree gchar *result = NULL;
  1976. + g_autofree gchar *object_id = NULL;
  1977. + g_autofree gchar *object_path = NULL;
  1978. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  1979. DLEYNA_LOG_DEBUG("Enter");
  1980. - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  1981. - &error, "ObjectID",
  1982. - G_TYPE_STRING, &object_id,
  1983. - "Result", G_TYPE_STRING, &result,
  1984. - NULL);
  1985. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  1986. + &error);
  1987. - if (!end || (object_id == NULL)) {
  1988. - message = (error != NULL) ? error->message : "Invalid result";
  1989. - DLEYNA_LOG_WARNING("Create Object operation failed: %s",
  1990. - message);
  1991. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  1992. + return;
  1993. + }
  1994. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  1995. - DLEYNA_ERROR_OPERATION_FAILED,
  1996. - "Create Object operation failed: %s",
  1997. - message);
  1998. + if(error == NULL) {
  1999. + gupnp_service_proxy_action_get_result(
  2000. + action, &error, "ObjectID", G_TYPE_STRING, &object_id,
  2001. + "Result", G_TYPE_STRING, &result, NULL);
  2002. + }
  2003. +
  2004. + if(error != NULL) {
  2005. + DLEYNA_LOG_WARNING("Create Object operation failed: %s", error->message);
  2006. +
  2007. + cb_data->error = g_error_new(
  2008. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  2009. + "Create Object operation failed: %s", error->message);
  2010. goto on_error;
  2011. }
  2012. @@ -4670,59 +4577,56 @@
  2013. object_id);
  2014. cb_data->task.result = g_variant_ref_sink(g_variant_new_object_path(
  2015. object_path));
  2016. - g_free(object_path);
  2017. -
  2018. on_error:
  2019. -
  2020. (void) g_idle_add(dls_async_task_complete, cb_data);
  2021. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  2022. -
  2023. - g_free(object_id);
  2024. - g_free(result);
  2025. -
  2026. - if (error)
  2027. - g_error_free(error);
  2028. DLEYNA_LOG_DEBUG("Exit");
  2029. }
  2030. -static void prv_generic_upload_cb(dls_async_task_t *cb_data,
  2031. - char *file_path,
  2032. - gchar *body,
  2033. - gsize body_length,
  2034. - const gchar *mime_type)
  2035. +static void prv_create_object_upload_cb(GObject *source, GAsyncResult *res,
  2036. + gpointer user_data)
  2037. {
  2038. - gchar *object_id = NULL;
  2039. - gchar *result = NULL;
  2040. + dls_async_task_t *cb_data = user_data;
  2041. + char *file_path = cb_data->task.ut.upload.file_path;
  2042. + gchar *body = NULL;
  2043. + gsize body_length = 0;
  2044. + const gchar *mime_type = cb_data->ut.upload.mime_type;
  2045. +
  2046. gchar *import_uri = NULL;
  2047. - gchar *object_path;
  2048. - const gchar *message;
  2049. - GError *error = NULL;
  2050. gboolean delete_needed = FALSE;
  2051. - gboolean end;
  2052. gint *upload_id;
  2053. - GUPnPDIDLLiteParser *parser = NULL;
  2054. + g_autoptr(GUPnPDIDLLiteParser) parser = NULL;
  2055. GVariant *out_p[2];
  2056. dls_device_upload_t *upload;
  2057. dls_device_upload_job_t *upload_job;
  2058. + g_autoptr(GError) error = NULL;
  2059. + g_autofree gchar *result = NULL;
  2060. + g_autofree gchar *object_id = NULL;
  2061. + g_autofree gchar *object_path = NULL;
  2062. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  2063. DLEYNA_LOG_DEBUG("Enter");
  2064. - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  2065. - &error, "ObjectID",
  2066. - G_TYPE_STRING, &object_id,
  2067. - "Result", G_TYPE_STRING, &result,
  2068. - NULL);
  2069. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  2070. + &error);
  2071. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  2072. + return;
  2073. + }
  2074. - if (!end || (object_id == NULL) || (result == NULL)) {
  2075. - message = (error != NULL) ? error->message : "Invalid result";
  2076. + if(error == NULL) {
  2077. + gupnp_service_proxy_action_get_result(
  2078. + action, &error, "ObjectID", G_TYPE_STRING, &object_id,
  2079. + "Result", G_TYPE_STRING, &result, NULL);
  2080. + }
  2081. +
  2082. + if(error != NULL) {
  2083. DLEYNA_LOG_WARNING("Create Object operation failed: %s",
  2084. - message);
  2085. + error->message);
  2086. +
  2087. + cb_data->error = g_error_new(
  2088. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  2089. + "Create Object operation failed: %s", error->message);
  2090. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  2091. - DLEYNA_ERROR_OPERATION_FAILED,
  2092. - "Create Object operation failed: %s",
  2093. - message);
  2094. goto on_error;
  2095. }
  2096. @@ -4771,9 +4675,9 @@
  2097. upload_job->device = cb_data->task.target.device;
  2098. upload_job->upload_id = (gint) cb_data->task.target.device->upload_id;
  2099. - soup_session_queue_message(upload->soup_session, upload->msg,
  2100. - prv_post_finished, upload_job);
  2101. - g_object_ref(upload->msg);
  2102. + soup_session_send_and_read_async(
  2103. + upload->soup_session, upload->msg, G_PRIORITY_DEFAULT,
  2104. + upload->cancellable, prv_post_finished, upload_job);
  2105. upload_id = g_new(gint, 1);
  2106. *upload_id = upload_job->upload_id;
  2107. @@ -4796,8 +4700,6 @@
  2108. if (cb_data->task.target.device->upload_id > G_MAXINT)
  2109. cb_data->task.target.device->upload_id = 0;
  2110. - g_free(object_path);
  2111. -
  2112. on_error:
  2113. if (cb_data->error && delete_needed) {
  2114. @@ -4805,49 +4707,28 @@
  2115. "Upload failed deleting created object with id %s",
  2116. object_id);
  2117. - cb_data->action = gupnp_service_proxy_begin_action(
  2118. - cb_data->proxy, "DestroyObject",
  2119. - prv_upload_delete_cb, cb_data,
  2120. - "ObjectID", G_TYPE_STRING, object_id,
  2121. - NULL);
  2122. + cb_data->action = gupnp_service_proxy_action_new(
  2123. + "DestroyObject", "ObjectID", G_TYPE_STRING, object_id,
  2124. + NULL);
  2125. + gupnp_service_proxy_call_action_async(
  2126. + cb_data->proxy, cb_data->action, cb_data->cancellable,
  2127. + prv_upload_delete_cb, cb_data);
  2128. +
  2129. + // Fire and forget operation, we unref the action here.
  2130. + gupnp_service_proxy_action_unref (cb_data->action);
  2131. } else {
  2132. (void) g_idle_add(dls_async_task_complete, cb_data);
  2133. - g_cancellable_disconnect(cb_data->cancellable,
  2134. - cb_data->cancel_id);
  2135. }
  2136. - g_free(object_id);
  2137. - g_free(import_uri);
  2138. -
  2139. - if (parser)
  2140. - g_object_unref(parser);
  2141. -
  2142. - g_free(result);
  2143. -
  2144. - if (error)
  2145. - g_error_free(error);
  2146. -
  2147. DLEYNA_LOG_DEBUG("Exit");
  2148. }
  2149. -static void prv_create_object_upload_cb(GUPnPServiceProxy *proxy,
  2150. - GUPnPServiceProxyAction *action,
  2151. - gpointer user_data)
  2152. -{
  2153. - dls_async_task_t *cb_data = user_data;
  2154. -
  2155. - prv_generic_upload_cb(cb_data,
  2156. - cb_data->task.ut.upload.file_path,
  2157. - NULL, 0,
  2158. - cb_data->ut.upload.mime_type);
  2159. -}
  2160. -
  2161. void dls_device_upload(dls_client_t *client,
  2162. dls_task_t *task, const gchar *parent_id)
  2163. {
  2164. dls_async_task_t *cb_data = (dls_async_task_t *)task;
  2165. dls_device_context_t *context;
  2166. - gchar *didl;
  2167. + g_autofree gchar *didl;
  2168. dls_async_upload_t *cb_task_data;
  2169. DLEYNA_LOG_DEBUG("Enter");
  2170. @@ -4869,19 +4750,13 @@
  2171. g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
  2172. (gpointer *)&cb_data->proxy);
  2173. - cb_data->action = gupnp_service_proxy_begin_action(
  2174. - cb_data->proxy, "CreateObject",
  2175. - prv_create_object_upload_cb, cb_data,
  2176. - "ContainerID", G_TYPE_STRING, parent_id,
  2177. - "Elements", G_TYPE_STRING, didl,
  2178. - NULL);
  2179. -
  2180. - cb_data->cancel_id = g_cancellable_connect(
  2181. - cb_data->cancellable,
  2182. - G_CALLBACK(dls_async_task_cancelled_cb),
  2183. - cb_data, NULL);
  2184. -
  2185. - g_free(didl);
  2186. + cb_data->action = gupnp_service_proxy_action_new(
  2187. + "CreateObject", "ContainerID", G_TYPE_STRING, parent_id,
  2188. + "Elements", G_TYPE_STRING, didl, NULL);
  2189. +
  2190. + gupnp_service_proxy_call_action_async(
  2191. + cb_data->proxy, cb_data->action, cb_data->cancellable,
  2192. + prv_create_object_upload_cb, cb_data);
  2193. DLEYNA_LOG_DEBUG("Exit");
  2194. }
  2195. @@ -4963,8 +4838,7 @@
  2196. }
  2197. if (upload->msg) {
  2198. - soup_session_cancel_message(upload->soup_session, upload->msg,
  2199. - SOUP_STATUS_CANCELLED);
  2200. + g_cancellable_cancel(upload->cancellable);
  2201. DLEYNA_LOG_DEBUG("Cancelling Upload %u ", upload_id);
  2202. }
  2203. @@ -4977,32 +4851,37 @@
  2204. return retval;
  2205. }
  2206. -static void prv_destroy_object_cb(GUPnPServiceProxy *proxy,
  2207. - GUPnPServiceProxyAction *action,
  2208. - gpointer user_data)
  2209. +static void prv_destroy_object_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  2210. {
  2211. - GError *upnp_error = NULL;
  2212. + g_autoptr(GError) upnp_error = NULL;
  2213. dls_async_task_t *cb_data = user_data;
  2214. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  2215. DLEYNA_LOG_DEBUG("Enter");
  2216. - if (!gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  2217. - &upnp_error,
  2218. - NULL)) {
  2219. - DLEYNA_LOG_WARNING("Destroy Object operation failed: %s",
  2220. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  2221. + &upnp_error);
  2222. +
  2223. + if(g_error_matches(upnp_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  2224. + return;
  2225. + }
  2226. +
  2227. + if(upnp_error == NULL) {
  2228. + gupnp_service_proxy_action_get_result(action, &upnp_error,
  2229. + NULL);
  2230. + }
  2231. +
  2232. + if(upnp_error != NULL) {
  2233. + DLEYNA_LOG_WARNING("Create Object operation failed: %s",
  2234. upnp_error->message);
  2235. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  2236. - DLEYNA_ERROR_OPERATION_FAILED,
  2237. - "Destroy Object operation failed: %s",
  2238. - upnp_error->message);
  2239. + cb_data->error = g_error_new(
  2240. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  2241. + "Create Object operation failed: %s",
  2242. + upnp_error->message);
  2243. }
  2244. (void) g_idle_add(dls_async_task_complete, cb_data);
  2245. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  2246. -
  2247. - if (upnp_error)
  2248. - g_error_free(upnp_error);
  2249. DLEYNA_LOG_DEBUG("Exit");
  2250. }
  2251. @@ -5022,15 +4901,12 @@
  2252. g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
  2253. (gpointer *)&cb_data->proxy);
  2254. - cb_data->action = gupnp_service_proxy_begin_action(
  2255. - cb_data->proxy, "DestroyObject",
  2256. - prv_destroy_object_cb, cb_data,
  2257. - "ObjectID", G_TYPE_STRING, task->target.id,
  2258. - NULL);
  2259. -
  2260. - cb_data->cancel_id = g_cancellable_connect(cb_data->cancellable,
  2261. - G_CALLBACK(dls_async_task_cancelled_cb),
  2262. - cb_data, NULL);
  2263. + cb_data->action = gupnp_service_proxy_action_new(
  2264. + "DestroyObject", "ObjectID", G_TYPE_STRING, task->target.id,
  2265. + NULL);
  2266. + gupnp_service_proxy_call_action_async(cb_data->proxy, cb_data->action,
  2267. + cb_data->cancellable,
  2268. + prv_destroy_object_cb, cb_data);
  2269. DLEYNA_LOG_DEBUG("Exit");
  2270. }
  2271. @@ -5041,7 +4917,7 @@
  2272. {
  2273. dls_async_task_t *cb_data = (dls_async_task_t *)task;
  2274. dls_device_context_t *context;
  2275. - gchar *didl;
  2276. + g_autofree gchar *didl = NULL;
  2277. DLEYNA_LOG_DEBUG("Enter");
  2278. @@ -5064,19 +4940,13 @@
  2279. g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
  2280. (gpointer *)&cb_data->proxy);
  2281. - cb_data->action = gupnp_service_proxy_begin_action(
  2282. - cb_data->proxy, "CreateObject",
  2283. - prv_create_container_cb, cb_data,
  2284. - "ContainerID", G_TYPE_STRING, parent_id,
  2285. - "Elements", G_TYPE_STRING, didl,
  2286. - NULL);
  2287. -
  2288. - cb_data->cancel_id = g_cancellable_connect(
  2289. - cb_data->cancellable,
  2290. - G_CALLBACK(dls_async_task_cancelled_cb),
  2291. - cb_data, NULL);
  2292. -
  2293. - g_free(didl);
  2294. + cb_data->action = gupnp_service_proxy_action_new(
  2295. + "CreateObject", "ContainerID", G_TYPE_STRING, parent_id,
  2296. + "Elements", G_TYPE_STRING, didl, NULL);
  2297. +
  2298. + gupnp_service_proxy_call_action_async(cb_data->proxy, cb_data->action,
  2299. + cb_data->cancellable,
  2300. + prv_create_container_cb, cb_data);
  2301. on_error:
  2302. @@ -5085,33 +4955,36 @@
  2303. return;
  2304. }
  2305. -static void prv_update_object_update_cb(GUPnPServiceProxy *proxy,
  2306. - GUPnPServiceProxyAction *action,
  2307. - gpointer user_data)
  2308. +static void prv_update_object_update_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  2309. {
  2310. - GError *upnp_error = NULL;
  2311. + g_autoptr(GError) upnp_error = NULL;
  2312. dls_async_task_t *cb_data = user_data;
  2313. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  2314. DLEYNA_LOG_DEBUG("Enter");
  2315. - if (!gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  2316. - &upnp_error,
  2317. - NULL)) {
  2318. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  2319. + &upnp_error);
  2320. + if(g_error_matches(upnp_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  2321. + return;
  2322. + }
  2323. +
  2324. + if(upnp_error == NULL) {
  2325. + gupnp_service_proxy_action_get_result(action, &upnp_error,
  2326. + NULL);
  2327. + }
  2328. +
  2329. + if(upnp_error != NULL) {
  2330. DLEYNA_LOG_WARNING("Update Object operation failed: %s",
  2331. upnp_error->message);
  2332. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  2333. - DLEYNA_ERROR_OPERATION_FAILED,
  2334. - "Update Object operation "
  2335. - " failed: %s",
  2336. - upnp_error->message);
  2337. + cb_data->error = g_error_new(
  2338. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  2339. + "Update Object operation failed: %s",
  2340. + upnp_error->message);
  2341. }
  2342. (void) g_idle_add(dls_async_task_complete, cb_data);
  2343. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  2344. -
  2345. - if (upnp_error)
  2346. - g_error_free(upnp_error);
  2347. DLEYNA_LOG_DEBUG("Exit");
  2348. }
  2349. @@ -5305,34 +5178,36 @@
  2350. DLEYNA_LOG_DEBUG("Exit");
  2351. }
  2352. -static void prv_update_object_browse_cb(GUPnPServiceProxy *proxy,
  2353. - GUPnPServiceProxyAction *action,
  2354. - gpointer user_data)
  2355. +static void prv_update_object_browse_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  2356. {
  2357. - GError *error = NULL;
  2358. + g_autoptr(GError) error = NULL;
  2359. dls_async_task_t *cb_data = user_data;
  2360. dls_async_update_t *cb_task_data = &cb_data->ut.update;
  2361. - GUPnPDIDLLiteParser *parser = NULL;
  2362. - gchar *result = NULL;
  2363. - const gchar *message;
  2364. - gboolean end;
  2365. + g_autoptr(GUPnPDIDLLiteParser) parser = NULL;
  2366. + g_autofree gchar *result = NULL;
  2367. + g_autoptr(GUPnPServiceProxyAction) action = NULL;
  2368. DLEYNA_LOG_DEBUG("Enter");
  2369. - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  2370. - &error,
  2371. - "Result", G_TYPE_STRING, &result,
  2372. - NULL);
  2373. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  2374. + &error);
  2375. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  2376. + return;
  2377. + }
  2378. - if (!end || (result == NULL)) {
  2379. - message = (error != NULL) ? error->message : "Invalid result";
  2380. - DLEYNA_LOG_WARNING("Browse Object operation failed: %s",
  2381. - message);
  2382. + if(error == NULL) {
  2383. + gupnp_service_proxy_action_get_result(
  2384. + action, &error, "Result", G_TYPE_STRING, &result, NULL);
  2385. + }
  2386. +
  2387. + if(error != NULL) {
  2388. + DLEYNA_LOG_WARNING("Browse operation failed: %s",
  2389. + error->message);
  2390. +
  2391. + cb_data->error = g_error_new(
  2392. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  2393. + "Browse operation failed: %s", error->message);
  2394. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  2395. - DLEYNA_ERROR_OPERATION_FAILED,
  2396. - "Browse operation failed: %s",
  2397. - message);
  2398. goto on_error;
  2399. }
  2400. @@ -5367,32 +5242,24 @@
  2401. goto on_error;
  2402. }
  2403. - cb_data->action = gupnp_service_proxy_begin_action(
  2404. - cb_data->proxy, "UpdateObject",
  2405. - prv_update_object_update_cb, cb_data,
  2406. - "ObjectID", G_TYPE_STRING, cb_data->task.target.id,
  2407. - "CurrentTagValue", G_TYPE_STRING,
  2408. - cb_task_data->current_tag_value,
  2409. - "NewTagValue", G_TYPE_STRING, cb_task_data->new_tag_value,
  2410. - NULL);
  2411. + cb_data->action = gupnp_service_proxy_action_new(
  2412. + "UpdateObject", "ObjectID", G_TYPE_STRING,
  2413. + cb_data->task.target.id, "CurrentTagValue", G_TYPE_STRING,
  2414. + cb_task_data->current_tag_value, "NewTagValue", G_TYPE_STRING,
  2415. + cb_task_data->new_tag_value, NULL);
  2416. +
  2417. + gupnp_service_proxy_call_action_async(
  2418. + cb_data->proxy, cb_data->action, cb_data->cancellable,
  2419. + prv_update_object_update_cb, cb_data);
  2420. goto no_complete;
  2421. on_error:
  2422. (void) g_idle_add(dls_async_task_complete, cb_data);
  2423. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  2424. no_complete:
  2425. - if (parser)
  2426. - g_object_unref(parser);
  2427. -
  2428. - g_free(result);
  2429. -
  2430. - if (error)
  2431. - g_error_free(error);
  2432. -
  2433. DLEYNA_LOG_DEBUG("Exit");
  2434. }
  2435. @@ -5412,50 +5279,48 @@
  2436. g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
  2437. (gpointer *)&cb_data->proxy);
  2438. - cb_data->action = gupnp_service_proxy_begin_action(
  2439. - cb_data->proxy, "Browse",
  2440. - prv_update_object_browse_cb, cb_data,
  2441. - "ObjectID", G_TYPE_STRING, task->target.id,
  2442. - "BrowseFlag", G_TYPE_STRING, "BrowseMetadata",
  2443. - "Filter", G_TYPE_STRING, upnp_filter,
  2444. - "StartingIndex", G_TYPE_INT, 0,
  2445. - "RequestedCount", G_TYPE_INT, 0,
  2446. - "SortCriteria", G_TYPE_STRING,
  2447. - "", NULL);
  2448. - cb_data->cancel_id = g_cancellable_connect(cb_data->cancellable,
  2449. - G_CALLBACK(dls_async_task_cancelled_cb),
  2450. - cb_data, NULL);
  2451. + cb_data->action = gupnp_service_proxy_action_new(
  2452. + "Browse", "ObjectID", G_TYPE_STRING, task->target.id,
  2453. + "BrowseFlag", G_TYPE_STRING, "BrowseMetadata", "Filter",
  2454. + G_TYPE_STRING, upnp_filter, "StartingIndex", G_TYPE_INT, 0,
  2455. + "RequestedCount", G_TYPE_INT, 0, "SortCriteria", G_TYPE_STRING,
  2456. + "", NULL);
  2457. +
  2458. + gupnp_service_proxy_call_action_async(
  2459. + cb_data->proxy, cb_data->action, cb_data->cancellable,
  2460. + prv_update_object_browse_cb, cb_data);
  2461. DLEYNA_LOG_DEBUG("Exit");
  2462. }
  2463. -static void prv_get_object_metadata_cb(GUPnPServiceProxy *proxy,
  2464. - GUPnPServiceProxyAction *action,
  2465. - gpointer user_data)
  2466. +static void prv_get_object_metadata_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  2467. {
  2468. - GError *error = NULL;
  2469. + g_autoptr(GError) error = NULL;
  2470. dls_async_task_t *cb_data = user_data;
  2471. - gchar *result = NULL;
  2472. - const gchar *message;
  2473. - gboolean end;
  2474. + g_autofree gchar *result = NULL;
  2475. + g_autoptr(GUPnPServiceProxyAction) action;
  2476. DLEYNA_LOG_DEBUG("Enter");
  2477. - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  2478. - &error,
  2479. - "Result", G_TYPE_STRING, &result,
  2480. - NULL);
  2481. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  2482. + &error);
  2483. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  2484. + return;
  2485. + }
  2486. - if (!end || (result == NULL)) {
  2487. - message = (error != NULL) ? error->message : "Invalid result";
  2488. - DLEYNA_LOG_WARNING("Browse Object operation failed: %s",
  2489. - message);
  2490. + if(error == NULL) {
  2491. + gupnp_service_proxy_action_get_result(
  2492. + action, &error, "Result", G_TYPE_STRING, &result, NULL);
  2493. + }
  2494. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  2495. - DLEYNA_ERROR_OPERATION_FAILED,
  2496. - "Browse operation failed: %s",
  2497. - message);
  2498. + if(error != NULL) {
  2499. + DLEYNA_LOG_WARNING("Browse operation failed: %s",
  2500. + error->message);
  2501. +
  2502. + cb_data->error = g_error_new(
  2503. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  2504. + "Browse operation failed: %s", error->message);
  2505. goto on_complete;
  2506. }
  2507. @@ -5463,15 +5328,9 @@
  2508. DLEYNA_LOG_DEBUG("prv_get_object_metadata_cb result: %s", result);
  2509. - g_free(result);
  2510. -
  2511. on_complete:
  2512. (void) g_idle_add(dls_async_task_complete, cb_data);
  2513. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  2514. -
  2515. - if (error)
  2516. - g_error_free(error);
  2517. DLEYNA_LOG_DEBUG("Exit");
  2518. }
  2519. @@ -5492,52 +5351,50 @@
  2520. g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
  2521. (gpointer *)&cb_data->proxy);
  2522. - cb_data->action = gupnp_service_proxy_begin_action(
  2523. - cb_data->proxy, "Browse",
  2524. - prv_get_object_metadata_cb, cb_data,
  2525. - "ObjectID", G_TYPE_STRING, task->target.id,
  2526. - "BrowseFlag", G_TYPE_STRING, "BrowseMetadata",
  2527. - "Filter", G_TYPE_STRING, "*",
  2528. - "StartingIndex", G_TYPE_INT, 0,
  2529. - "RequestedCount", G_TYPE_INT, 0,
  2530. - "SortCriteria", G_TYPE_STRING, "",
  2531. - NULL);
  2532. + cb_data->action = gupnp_service_proxy_action_new(
  2533. + "Browse", "ObjectID", G_TYPE_STRING, task->target.id,
  2534. + "BrowseFlag", G_TYPE_STRING, "BrowseMetadata", "Filter",
  2535. + G_TYPE_STRING, "*", "StartingIndex", G_TYPE_INT, 0,
  2536. + "RequestedCount", G_TYPE_INT, 0, "SortCriteria", G_TYPE_STRING,
  2537. + "", NULL);
  2538. +
  2539. + gupnp_service_proxy_call_action_async(
  2540. + cb_data->proxy, cb_data->action, cb_data->cancellable,
  2541. + prv_get_object_metadata_cb, cb_data);
  2542. - cb_data->cancel_id = g_cancellable_connect(cb_data->cancellable,
  2543. - G_CALLBACK(dls_async_task_cancelled_cb),
  2544. - cb_data, NULL);
  2545. DLEYNA_LOG_DEBUG("Exit");
  2546. }
  2547. -static void prv_create_reference_cb(GUPnPServiceProxy *proxy,
  2548. - GUPnPServiceProxyAction *action,
  2549. - gpointer user_data)
  2550. +static void prv_create_reference_cb(GObject *source, GAsyncResult *res, gpointer user_data)
  2551. {
  2552. - GError *error = NULL;
  2553. + g_autoptr(GError) error = NULL;
  2554. dls_async_task_t *cb_data = user_data;
  2555. - const gchar *message;
  2556. - gchar *object_id = NULL;
  2557. - gchar *object_path;
  2558. - gboolean end;
  2559. + g_autofree gchar *object_id = NULL;
  2560. + g_autofree gchar *object_path = NULL;
  2561. + g_autoptr(GUPnPServiceProxyAction) action;
  2562. DLEYNA_LOG_DEBUG("Enter");
  2563. - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
  2564. - &error,
  2565. - "NewID", G_TYPE_STRING, &object_id,
  2566. - NULL);
  2567. - if (!end || (object_id == NULL)) {
  2568. - message = (error != NULL) ? error->message : "Invalid result";
  2569. - DLEYNA_LOG_WARNING("CreateReference operation failed: %s",
  2570. - message);
  2571. + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
  2572. + &error);
  2573. + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
  2574. + return;
  2575. + }
  2576. - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  2577. - DLEYNA_ERROR_OPERATION_FAILED,
  2578. - "Update Object operation "
  2579. - " failed: %s",
  2580. - message);
  2581. + if(error == NULL) {
  2582. + gupnp_service_proxy_action_get_result(action, &error, "NewID",
  2583. + G_TYPE_STRING, &object_id,
  2584. + NULL);
  2585. + }
  2586. +
  2587. + if(error != NULL) {
  2588. + DLEYNA_LOG_WARNING("CreateReference operation failed: %s",
  2589. + error->message);
  2590. + cb_data->error = g_error_new(
  2591. + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
  2592. + "CreateReference operation failed: %s", error->message);
  2593. goto on_error;
  2594. }
  2595. @@ -5548,17 +5405,9 @@
  2596. cb_data->task.result = g_variant_ref_sink(g_variant_new_object_path(
  2597. object_path));
  2598. - g_free(object_path);
  2599. -
  2600. on_error:
  2601. (void) g_idle_add(dls_async_task_complete, cb_data);
  2602. - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
  2603. -
  2604. - g_free(object_id);
  2605. -
  2606. - if (error != NULL)
  2607. - g_error_free(error);
  2608. DLEYNA_LOG_DEBUG("Exit");
  2609. }
  2610. @@ -5568,8 +5417,8 @@
  2611. {
  2612. dls_async_task_t *cb_data = (dls_async_task_t *)task;
  2613. dls_device_context_t *context;
  2614. - gchar *i_root = NULL;
  2615. - gchar *i_id = NULL;
  2616. + g_autofree gchar *i_root = NULL;
  2617. + g_autofree gchar *i_id = NULL;
  2618. gchar *path = cb_data->task.ut.create_reference.item_path;
  2619. DLEYNA_LOG_DEBUG("Enter");
  2620. @@ -5594,23 +5443,15 @@
  2621. g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
  2622. (gpointer *)&cb_data->proxy);
  2623. - cb_data->action = gupnp_service_proxy_begin_action(
  2624. - cb_data->proxy, "CreateReference",
  2625. - prv_create_reference_cb, cb_data,
  2626. - "ContainerID", G_TYPE_STRING, task->target.id,
  2627. - "ObjectID", G_TYPE_STRING, i_id,
  2628. - NULL);
  2629. -
  2630. - cb_data->cancel_id = g_cancellable_connect(
  2631. - cb_data->cancellable,
  2632. - G_CALLBACK(dls_async_task_cancelled_cb),
  2633. - cb_data, NULL);
  2634. + cb_data->action = gupnp_service_proxy_action_new(
  2635. + "CreateReference", "ContainerID", G_TYPE_STRING,
  2636. + task->target.id, "ObjectID", G_TYPE_STRING, i_id, NULL);
  2637. +
  2638. + gupnp_service_proxy_call_action_async(cb_data->proxy, cb_data->action,
  2639. + cb_data->cancellable,
  2640. + prv_create_reference_cb, cb_data);
  2641. on_error:
  2642. -
  2643. - g_free(i_root);
  2644. - g_free(i_id);
  2645. -
  2646. DLEYNA_LOG_DEBUG("Exit");
  2647. }
  2648. @@ -5618,9 +5459,11 @@
  2649. {
  2650. GVariant *out_p[2];
  2651. + gsize size;
  2652. + gconstpointer data = g_bytes_get_data(device->icon.bytes, &size);
  2653. out_p[0] = g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE,
  2654. - device->icon.bytes,
  2655. - device->icon.size,
  2656. + data,
  2657. + size,
  2658. 1);
  2659. out_p[1] = g_variant_new_string(device->icon.mime_type);
  2660. task->result = g_variant_ref_sink(g_variant_new_tuple(out_p, 2));
  2661. @@ -5634,8 +5477,7 @@
  2662. dls_async_task_cancelled_cb(cancellable, download->task);
  2663. if (download->msg) {
  2664. - soup_session_cancel_message(download->session, download->msg,
  2665. - SOUP_STATUS_CANCELLED);
  2666. + g_cancellable_cancel(download->cancellable);
  2667. DLEYNA_LOG_DEBUG("Cancelling device icon download");
  2668. }
  2669. }
  2670. @@ -5644,31 +5486,39 @@
  2671. {
  2672. if (download->msg)
  2673. g_object_unref(download->msg);
  2674. + if(download->cancellable)
  2675. + g_object_unref(download->cancellable);
  2676. g_object_unref(download->session);
  2677. g_free(download);
  2678. }
  2679. -static void prv_get_icon_session_cb(SoupSession *session,
  2680. - SoupMessage *msg,
  2681. +static void prv_get_icon_session_cb(GObject *source,
  2682. + GAsyncResult *res,
  2683. gpointer user_data)
  2684. {
  2685. dls_device_download_t *download = (dls_device_download_t *)user_data;
  2686. dls_async_task_t *cb_data = (dls_async_task_t *)download->task;
  2687. dls_device_t *device = (dls_device_t *)cb_data->task.target.device;
  2688. + g_autoptr(GError) error = NULL;
  2689. + GBytes *data;
  2690. +
  2691. + data = soup_session_send_and_read_finish(SOUP_SESSION(source), res,
  2692. + &error);
  2693. - if (msg->status_code == SOUP_STATUS_CANCELLED)
  2694. + if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
  2695. goto out;
  2696. - if (SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) {
  2697. - device->icon.size = msg->response_body->length;
  2698. - device->icon.bytes = g_malloc(device->icon.size);
  2699. - memcpy(device->icon.bytes, msg->response_body->data,
  2700. - device->icon.size);
  2701. + SoupStatus status = soup_message_get_status(download->msg);
  2702. +
  2703. + if (SOUP_STATUS_IS_SUCCESSFUL(status)) {
  2704. + device->icon.bytes = data;
  2705. prv_build_icon_result(device, &cb_data->task);
  2706. } else {
  2707. DLEYNA_LOG_DEBUG("Failed to GET device icon: %s",
  2708. - msg->reason_phrase);
  2709. + error != NULL
  2710. + ? error->message
  2711. + : soup_message_get_reason_phrase(download->msg));
  2712. cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  2713. DLEYNA_ERROR_OPERATION_FAILED,
  2714. @@ -5689,10 +5539,10 @@
  2715. dls_device_context_t *context;
  2716. dls_async_task_t *cb_data = (dls_async_task_t *)task;
  2717. dls_device_t *device = task->target.device;
  2718. - gchar *url;
  2719. + g_autofree gchar *url;
  2720. dls_device_download_t *download;
  2721. - if (device->icon.size != 0) {
  2722. + if (device->icon.bytes != NULL) {
  2723. prv_build_icon_result(device, task);
  2724. goto end;
  2725. }
  2726. @@ -5714,6 +5564,7 @@
  2727. download->session = soup_session_new();
  2728. download->msg = soup_message_new(SOUP_METHOD_GET, url);
  2729. download->task = cb_data;
  2730. + download->cancellable = g_cancellable_new();
  2731. if (!download->msg) {
  2732. DLEYNA_LOG_WARNING("Invalid URL %s", url);
  2733. @@ -5732,11 +5583,9 @@
  2734. G_CALLBACK(prv_get_icon_cancelled),
  2735. download, NULL);
  2736. - g_object_ref(download->msg);
  2737. - soup_session_queue_message(download->session, download->msg,
  2738. - prv_get_icon_session_cb, download);
  2739. -
  2740. - g_free(url);
  2741. + soup_session_send_and_read_async(
  2742. + download->session, download->msg, G_PRIORITY_DEFAULT,
  2743. + download->cancellable, prv_get_icon_session_cb, download);
  2744. return;
  2745. diff -Nuar a/libdleyna/server/device.h b/libdleyna/server/device.h
  2746. --- a/libdleyna/server/device.h 2021-10-26 18:17:55.000000000 +0300
  2747. +++ b/libdleyna/server/device.h 2022-06-02 23:36:05.000000000 +0300
  2748. @@ -64,8 +64,7 @@
  2749. typedef struct dls_device_icon_t_ dls_device_icon_t;
  2750. struct dls_device_icon_t_ {
  2751. gchar *mime_type;
  2752. - guchar *bytes;
  2753. - gsize size;
  2754. + GBytes *bytes;
  2755. };
  2756. struct dls_device_t_ {
  2757. diff -Nuar a/libdleyna/server/manager.c b/libdleyna/server/manager.c
  2758. --- a/libdleyna/server/manager.c 2021-10-26 18:17:55.000000000 +0300
  2759. +++ b/libdleyna/server/manager.c 2022-06-02 23:36:05.000000000 +0300
  2760. @@ -20,13 +20,14 @@
  2761. *
  2762. */
  2763. +#include <config.h>
  2764. +
  2765. #include <glib.h>
  2766. #include <string.h>
  2767. #include <libdleyna/core/error.h>
  2768. #include <libdleyna/core/log.h>
  2769. -#include <libdleyna/core/service-task.h>
  2770. -#include <libdleyna/core/white-list.h>
  2771. +#include <libdleyna/core/context-filter.h>
  2772. #include "interface.h"
  2773. #include "manager.h"
  2774. @@ -35,10 +36,10 @@
  2775. struct dls_manager_t_ {
  2776. dleyna_connector_id_t connection;
  2777. GUPnPContextManager *cm;
  2778. - dleyna_white_list_t *wl;
  2779. + dleyna_context_filter_t *cf;
  2780. };
  2781. -static void prv_wl_notify_prop(dls_manager_t *manager,
  2782. +static void prv_cf_notify_prop(dls_manager_t *manager,
  2783. const gchar *prop_name,
  2784. GVariant *prop_val)
  2785. {
  2786. @@ -64,13 +65,13 @@
  2787. GUPnPContextManager *connection_manager)
  2788. {
  2789. dls_manager_t *manager = g_new0(dls_manager_t, 1);
  2790. - GUPnPWhiteList *gupnp_wl;
  2791. + GUPnPContextFilter *gupnp_cf;
  2792. - gupnp_wl = gupnp_context_manager_get_white_list(connection_manager);
  2793. + gupnp_cf = gupnp_context_manager_get_context_filter(connection_manager);
  2794. manager->connection = connection;
  2795. manager->cm = connection_manager;
  2796. - manager->wl = dleyna_white_list_new(gupnp_wl);
  2797. + manager->cf = dleyna_context_filter_new(gupnp_cf);
  2798. return manager;
  2799. }
  2800. @@ -78,14 +79,14 @@
  2801. void dls_manager_delete(dls_manager_t *manager)
  2802. {
  2803. if (manager != NULL) {
  2804. - dleyna_white_list_delete(manager->wl);
  2805. + dleyna_context_filter_delete(manager->cf);
  2806. g_free(manager);
  2807. }
  2808. }
  2809. -dleyna_white_list_t *dls_manager_get_white_list(dls_manager_t *manager)
  2810. +dleyna_context_filter_t *dls_manager_get_context_filter(dls_manager_t *manager)
  2811. {
  2812. - return manager->wl;
  2813. + return manager->cf;
  2814. }
  2815. void dls_manager_get_all_props(dls_manager_t *manager,
  2816. @@ -188,7 +189,7 @@
  2817. if (*error == NULL) {
  2818. prop_val = g_variant_new_boolean(never_quit);
  2819. - prv_wl_notify_prop(manager,
  2820. + prv_cf_notify_prop(manager,
  2821. DLS_INTERFACE_PROP_NEVER_QUIT,
  2822. prop_val);
  2823. }
  2824. @@ -198,7 +199,7 @@
  2825. return;
  2826. }
  2827. -static void prv_set_prop_wl_enabled(dls_manager_t *manager,
  2828. +static void prv_set_prop_cf_enabled(dls_manager_t *manager,
  2829. dleyna_settings_t *settings,
  2830. gboolean enabled,
  2831. GError **error)
  2832. @@ -208,20 +209,20 @@
  2833. DLEYNA_LOG_DEBUG("Enter %d", enabled);
  2834. - old_val = dleyna_settings_is_white_list_enabled(settings);
  2835. + old_val = dleyna_settings_is_context_filter_enabled(settings);
  2836. if (old_val == enabled)
  2837. goto exit;
  2838. /* If no error, the white list will be updated in the reload callack
  2839. */
  2840. - dleyna_settings_set_white_list_enabled(settings, enabled, error);
  2841. + dleyna_settings_set_context_filter_enabled(settings, enabled, error);
  2842. if (*error == NULL) {
  2843. - dleyna_white_list_enable(manager->wl, enabled);
  2844. + dleyna_context_filter_enable(manager->cf, enabled);
  2845. prop_val = g_variant_new_boolean(enabled);
  2846. - prv_wl_notify_prop(manager,
  2847. + prv_cf_notify_prop(manager,
  2848. DLS_INTERFACE_PROP_WHITE_LIST_ENABLED,
  2849. prop_val);
  2850. }
  2851. @@ -231,7 +232,7 @@
  2852. return;
  2853. }
  2854. -static void prv_set_prop_wl_entries(dls_manager_t *manager,
  2855. +static void prv_set_prop_cf_entries(dls_manager_t *manager,
  2856. dleyna_settings_t *settings,
  2857. GVariant *entries,
  2858. GError **error)
  2859. @@ -250,13 +251,13 @@
  2860. /* If no error, the white list will be updated in the reload callack
  2861. * callack
  2862. */
  2863. - dleyna_settings_set_white_list_entries(settings, entries, error);
  2864. + dleyna_settings_set_context_filter_entries(settings, entries, error);
  2865. if (*error == NULL) {
  2866. - dleyna_white_list_clear(manager->wl);
  2867. - dleyna_white_list_add_entries(manager->wl, entries);
  2868. + dleyna_context_filter_clear(manager->cf);
  2869. + dleyna_context_filter_add_entries(manager->cf, entries);
  2870. - prv_wl_notify_prop(manager,
  2871. + prv_cf_notify_prop(manager,
  2872. DLS_INTERFACE_PROP_WHITE_LIST_ENTRIES,
  2873. entries);
  2874. }
  2875. @@ -299,11 +300,11 @@
  2876. g_variant_get_boolean(param),
  2877. &error);
  2878. else if (!strcmp(name, DLS_INTERFACE_PROP_WHITE_LIST_ENABLED))
  2879. - prv_set_prop_wl_enabled(manager, settings,
  2880. + prv_set_prop_cf_enabled(manager, settings,
  2881. g_variant_get_boolean(param),
  2882. &error);
  2883. else if (!strcmp(name, DLS_INTERFACE_PROP_WHITE_LIST_ENTRIES))
  2884. - prv_set_prop_wl_entries(manager, settings, param, &error);
  2885. + prv_set_prop_cf_entries(manager, settings, param, &error);
  2886. else
  2887. cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
  2888. DLEYNA_ERROR_UNKNOWN_PROPERTY,
  2889. diff -Nuar a/libdleyna/server/manager.h b/libdleyna/server/manager.h
  2890. --- a/libdleyna/server/manager.h 2021-10-26 18:17:55.000000000 +0300
  2891. +++ b/libdleyna/server/manager.h 2022-06-02 23:36:05.000000000 +0300
  2892. @@ -26,6 +26,7 @@
  2893. #include <libdleyna/core/connector.h>
  2894. #include <libdleyna/core/settings.h>
  2895. #include <libgupnp/gupnp-context-manager.h>
  2896. +#include <libdleyna/core/context-filter.h>
  2897. #include "task.h"
  2898. @@ -37,7 +38,7 @@
  2899. void dls_manager_delete(dls_manager_t *manager);
  2900. -dleyna_white_list_t *dls_manager_get_white_list(dls_manager_t *manager);
  2901. +dleyna_context_filter_t *dls_manager_get_context_filter(dls_manager_t *manager);
  2902. void dls_manager_get_all_props(dls_manager_t *manager,
  2903. dleyna_settings_t *settings,
  2904. diff -Nuar a/libdleyna/server/meson.build b/libdleyna/server/meson.build
  2905. --- a/libdleyna/server/meson.build 2021-10-26 18:17:55.000000000 +0300
  2906. +++ b/libdleyna/server/meson.build 2022-06-02 23:36:05.000000000 +0300
  2907. @@ -62,7 +62,7 @@
  2908. name: 'dleyna-server-service-1.0',
  2909. description: 'UPnP & DLNA server library',
  2910. version: meson.project_version(),
  2911. - requires: ['gupnp-1.2', 'glib-2.0', 'gio-2.0', 'dleyna-core-1.0'],
  2912. + requires: ['gupnp-1.6', 'glib-2.0', 'gio-2.0', 'dleyna-core-1.0'],
  2913. install_dir: join_paths(get_option('prefix'), get_option('libdir'), 'pkgconfig')
  2914. )
  2915. diff -Nuar a/libdleyna/server/props.c b/libdleyna/server/props.c
  2916. --- a/libdleyna/server/props.c 2021-10-26 18:17:55.000000000 +0300
  2917. +++ b/libdleyna/server/props.c 2022-06-02 23:36:05.000000000 +0300
  2918. @@ -2105,7 +2105,7 @@
  2919. {
  2920. GVariant *result;
  2921. - result = dleyna_settings_white_list_entries(settings);
  2922. + result = dleyna_settings_context_filter_entries(settings);
  2923. if (result == NULL)
  2924. result = g_variant_new("as", NULL);
  2925. @@ -2119,7 +2119,7 @@
  2926. dleyna_settings_is_never_quit(settings));
  2927. prv_add_bool_prop(vb, DLS_INTERFACE_PROP_WHITE_LIST_ENABLED,
  2928. - dleyna_settings_is_white_list_enabled(settings));
  2929. + dleyna_settings_is_context_filter_enabled(settings));
  2930. g_variant_builder_add(vb, "{sv}", DLS_INTERFACE_PROP_WHITE_LIST_ENTRIES,
  2931. prv_build_wl_entries(settings));
  2932. @@ -2138,7 +2138,7 @@
  2933. b_value = dleyna_settings_is_never_quit(settings);
  2934. retval = g_variant_ref_sink(g_variant_new_boolean(b_value));
  2935. } else if (!strcmp(prop, DLS_INTERFACE_PROP_WHITE_LIST_ENABLED)) {
  2936. - b_value = dleyna_settings_is_white_list_enabled(settings);
  2937. + b_value = dleyna_settings_is_context_filter_enabled(settings);
  2938. retval = g_variant_ref_sink(g_variant_new_boolean(b_value));
  2939. } else if (!strcmp(prop, DLS_INTERFACE_PROP_WHITE_LIST_ENTRIES)) {
  2940. retval = g_variant_ref_sink(prv_build_wl_entries(settings));
  2941. diff -Nuar a/libdleyna/server/server.c b/libdleyna/server/server.c
  2942. --- a/libdleyna/server/server.c 2021-10-26 18:17:55.000000000 +0300
  2943. +++ b/libdleyna/server/server.c 2022-06-02 23:36:05.000000000 +0300
  2944. @@ -21,15 +21,17 @@
  2945. *
  2946. */
  2947. +#include <config.h>
  2948. +
  2949. #include <glib.h>
  2950. #include <string.h>
  2951. #include <libdleyna/core/connector.h>
  2952. +#include <libdleyna/core/context-filter.h>
  2953. #include <libdleyna/core/control-point.h>
  2954. #include <libdleyna/core/error.h>
  2955. #include <libdleyna/core/log.h>
  2956. #include <libdleyna/core/task-processor.h>
  2957. -#include <libdleyna/core/white-list.h>
  2958. #include "async.h"
  2959. #include "client.h"
  2960. @@ -1293,21 +1295,21 @@
  2961. return g_context.upnp;
  2962. }
  2963. -static void prv_white_list_init(void)
  2964. +static void prv_context_filter_init(void)
  2965. {
  2966. gboolean enabled;
  2967. GVariant *entries;
  2968. - dleyna_white_list_t *wl;
  2969. + dleyna_context_filter_t *wl;
  2970. DLEYNA_LOG_DEBUG("Enter");
  2971. - enabled = dleyna_settings_is_white_list_enabled(g_context.settings);
  2972. - entries = dleyna_settings_white_list_entries(g_context.settings);
  2973. + enabled = dleyna_settings_is_context_filter_enabled(g_context.settings);
  2974. + entries = dleyna_settings_context_filter_entries(g_context.settings);
  2975. - wl = dls_manager_get_white_list(g_context.manager);
  2976. + wl = dls_manager_get_context_filter(g_context.manager);
  2977. - dleyna_white_list_enable(wl, enabled);
  2978. - dleyna_white_list_add_entries(wl, entries);
  2979. + dleyna_context_filter_enable(wl, enabled);
  2980. + dleyna_context_filter_add_entries(wl, entries);
  2981. DLEYNA_LOG_DEBUG("Exit");
  2982. }
  2983. @@ -1340,7 +1342,7 @@
  2984. dls_upnp_get_context_manager(
  2985. g_context.upnp));
  2986. - prv_white_list_init();
  2987. + prv_context_filter_init();
  2988. } else {
  2989. retval = FALSE;
  2990. }
  2991. diff -Nuar a/libdleyna/server/upnp.c b/libdleyna/server/upnp.c
  2992. --- a/libdleyna/server/upnp.c 2021-10-26 18:17:55.000000000 +0300
  2993. +++ b/libdleyna/server/upnp.c 2022-06-02 23:36:05.000000000 +0300
  2994. @@ -20,6 +20,8 @@
  2995. *
  2996. */
  2997. +#include <config.h>
  2998. +
  2999. #include <string.h>
  3000. #include <libgssdp/gssdp-resource-browser.h>
  3001. @@ -28,7 +30,7 @@
  3002. #include <libdleyna/core/error.h>
  3003. #include <libdleyna/core/log.h>
  3004. -#include <libdleyna/core/service-task.h>
  3005. +#include <libdleyna/core/gasync-task.h>
  3006. #include "async.h"
  3007. #include "device.h"
  3008. @@ -123,12 +125,12 @@
  3009. queue_id = dleyna_task_processor_add_queue(
  3010. dls_server_get_task_processor(),
  3011. - dleyna_service_task_create_source(),
  3012. + dleyna_gasync_task_create_source(),
  3013. DLS_SERVER_SINK,
  3014. DLEYNA_TASK_QUEUE_FLAG_AUTO_REMOVE,
  3015. - dleyna_service_task_process_cb,
  3016. - dleyna_service_task_cancel_cb,
  3017. - dleyna_service_task_delete_cb);
  3018. + dleyna_gasync_task_process_cb,
  3019. + dleyna_gasync_task_cancel_cb,
  3020. + dleyna_gasync_task_delete_cb);
  3021. dleyna_task_queue_set_finally(queue_id, prv_device_chain_end);
  3022. dleyna_task_queue_set_user_data(queue_id, *priv_t);
  3023. @@ -212,7 +214,7 @@
  3024. udn = gupnp_device_info_get_udn(device_proxy);
  3025. ip_address = gssdp_client_get_host_ip(
  3026. - GSSDP_CLIENT(gupnp_control_point_get_context(cp)));
  3027. + gssdp_resource_browser_get_client(GSSDP_RESOURCE_BROWSER(cp)));
  3028. if (!udn || !ip_address)
  3029. goto on_error;
  3030. @@ -352,7 +354,7 @@
  3031. udn = gupnp_device_info_get_udn((GUPnPDeviceInfo *)proxy);
  3032. ip_address = gssdp_client_get_host_ip(
  3033. - GSSDP_CLIENT(gupnp_control_point_get_context(cp)));
  3034. + gssdp_resource_browser_get_client(GSSDP_RESOURCE_BROWSER(cp)));
  3035. if (!udn || !ip_address)
  3036. goto on_error;
  3037. diff -Nuar a/meson.build b/meson.build
  3038. --- a/meson.build 2021-10-26 18:17:55.000000000 +0300
  3039. +++ b/meson.build 2022-06-02 23:36:05.000000000 +0300
  3040. @@ -1,4 +1,4 @@
  3041. -project('dleyna-server', 'c', version: '0.7.2')
  3042. +project('dleyna-server', 'c', version: '0.8.0')
  3043. pkg = import('pkgconfig')
  3044. @@ -67,12 +67,12 @@
  3045. glib = dependency('glib-2.0', version: '>= 2.28')
  3046. gio = dependency('gio-2.0', version: '>=2.28')
  3047. -gssdp = dependency('gssdp-1.2', version: '>= 1.2.0')
  3048. -gupnp = dependency('gupnp-1.2', version: '>= 1.2.0')
  3049. +gssdp = dependency('gssdp-1.6', version: '>= 1.2.0')
  3050. +gupnp = dependency('gupnp-1.6', version: '>= 1.2.0')
  3051. gupnp_av = dependency('gupnp-av-1.0', version: '>= 0.12.9')
  3052. gupnp_dlna = dependency('gupnp-dlna-2.0', version: '>= 0.9.4')
  3053. -soup = dependency('libsoup-2.4', version: '>= 2.28.2')
  3054. -dleyna_core = dependency('dleyna-core-1.0', version: '>= 0.6.0', fallback: 'dleyna-core-1.0')
  3055. +soup = dependency('libsoup-3.0', version: '>= 3.0')
  3056. +dleyna_core = dependency('dleyna-core-1.0', version: '>= 0.8.0', fallback: 'dleyna-core-1.0')
  3057. libxml2 = dependency('libxml-2.0')
  3058. cc = meson.get_compiler('c')