123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495 |
- diff -Nuar a/libdleyna/server/async.c b/libdleyna/server/async.c
- --- a/libdleyna/server/async.c 2021-10-26 18:17:55.000000000 +0300
- +++ b/libdleyna/server/async.c 2022-06-02 23:36:05.000000000 +0300
- @@ -82,10 +82,6 @@
- {
- dls_async_task_t *cb_data = user_data;
-
- - if (cb_data->proxy != NULL)
- - gupnp_service_proxy_cancel_action(cb_data->proxy,
- - cb_data->action);
- -
- if (!cb_data->error)
- cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- DLEYNA_ERROR_CANCELLED,
- diff -Nuar a/libdleyna/server/device.c b/libdleyna/server/device.c
- --- a/libdleyna/server/device.c 2021-10-26 18:17:55.000000000 +0300
- +++ b/libdleyna/server/device.c 2022-06-02 23:36:05.000000000 +0300
- @@ -20,6 +20,8 @@
- *
- */
-
- +#include <config.h>
- +
- #include <string.h>
- #include <stdint.h>
- #include <stdio.h>
- @@ -45,7 +47,7 @@
- #include <libdleyna/core/core.h>
- #include <libdleyna/core/error.h>
- #include <libdleyna/core/log.h>
- -#include <libdleyna/core/service-task.h>
- +#include <libdleyna/core/gasync-task.h>
-
- #include "device.h"
- #include "interface.h"
- @@ -90,6 +92,7 @@
- struct dls_device_upload_t_ {
- SoupSession *soup_session;
- SoupMessage *msg;
- + GCancellable *cancellable;
- GMappedFile *mapped_file;
- gchar *body;
- gsize body_length;
- @@ -108,6 +111,7 @@
- typedef struct dls_device_download_t_ dls_device_download_t;
- struct dls_device_download_t_ {
- SoupSession *session;
- + GCancellable *cancellable;
- SoupMessage *msg;
- dls_async_task_t *task;
- };
- @@ -165,13 +169,12 @@
- static void prv_get_sr_token_for_props(GUPnPServiceProxy *proxy,
- const dls_device_t *device,
- dls_async_task_t *cb_data);
- -static void prv_browse_objects_end_action_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- +static void prv_browse_objects_end_action_cb(GObject *target,
- + GAsyncResult *res,
- gpointer user_data);
- -static GUPnPServiceProxyAction *prv_browse_objects_begin_action_cb(
- - dleyna_service_task_t *task,
- - GUPnPServiceProxy *proxy,
- - gboolean *failed);
- +static gboolean prv_browse_objects_begin_action_cb(
- + dleyna_gasync_task_t *task,
- + GObject *target);
-
- static void prv_get_sleeping_for_props(GUPnPServiceProxy *proxy,
- const dls_device_t *device,
- @@ -375,7 +378,7 @@
- g_variant_unref(dev->sort_ext_caps);
- g_variant_unref(dev->feature_list);
- g_free(dev->icon.mime_type);
- - g_free(dev->icon.bytes);
- + g_bytes_unref(dev->icon.bytes);
- g_free(dev);
- }
- }
- @@ -1232,49 +1235,52 @@
- g_error_free(error);
- }
-
- -static void prv_get_feature_list_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- +static void prv_get_feature_list_cb(GObject *source, GAsyncResult *res,
- gpointer user_data)
- {
- - gchar *result = NULL;
- - gboolean end;
- - GError *error = NULL;
- - prv_new_device_ct_t *priv_t = (prv_new_device_ct_t *)user_data;
- + g_autofree gchar *result = NULL;
- + g_autoptr(GError) error = NULL;
- + dleyna_gasync_task_t *task = user_data;
- + prv_new_device_ct_t *priv_t =
- + (prv_new_device_ct_t *) dleyna_gasync_task_get_user_data(task);
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
- +
- + action = gupnp_service_proxy_call_action_finish(
- + GUPNP_SERVICE_PROXY(source), res, &error);
- +
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- priv_t->dev->construct_step++;
- - end = gupnp_service_proxy_end_action(proxy, action, &error,
- + if (error == NULL) {
- + gupnp_service_proxy_action_get_result(action, &error,
- "FeatureList", G_TYPE_STRING,
- &result, NULL);
- + }
-
- - if (!end || (result == NULL)) {
- + if (error != NULL) {
- DLEYNA_LOG_WARNING("GetFeatureList operation failed: %s",
- - ((error != NULL) ? error->message
- - : "Invalid result"));
- - goto on_error;
- - }
- + error->message);
- + } else {
- + DLEYNA_LOG_DEBUG("GetFeatureList result: %s", result);
-
- - DLEYNA_LOG_DEBUG("GetFeatureList result: %s", result);
- + prv_get_feature_list_analyze(priv_t->dev, result);
- + }
-
- - prv_get_feature_list_analyze(priv_t->dev, result);
- + dleyna_task_queue_task_completed (((dleyna_task_atom_t *) task)->queue_id);
- +}
-
- -on_error:
- - if (error != NULL)
- - g_error_free(error);
- +static gboolean prv_get_feature_list(dleyna_gasync_task_t *task, GObject *proxy)
- +{
- + GUPnPServiceProxyAction *action =
- + gupnp_service_proxy_action_new("GetFeatureList", NULL);
-
- - g_free(result);
- -}
- + gupnp_service_proxy_call_action_async(
- + GUPNP_SERVICE_PROXY(proxy), action, dleyna_gasync_task_get_cancellable(task),
- + prv_get_feature_list_cb, task);
-
- -static GUPnPServiceProxyAction *prv_get_feature_list(
- - dleyna_service_task_t *task,
- - GUPnPServiceProxy *proxy,
- - gboolean *failed)
- -{
- - *failed = FALSE;
- -
- - return gupnp_service_proxy_begin_action(
- - proxy, "GetFeatureList",
- - dleyna_service_task_begin_action_cb,
- - task, NULL);
- + return FALSE;
- }
-
- static void prv_get_sort_ext_capabilities_analyze(dls_device_t *device,
- @@ -1310,51 +1316,56 @@
- #endif
- }
-
- -static void prv_get_sort_ext_capabilities_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_get_sort_ext_capabilities_cb(GObject *source, GAsyncResult *res,
- + gpointer user_data)
- {
- - gchar *result = NULL;
- - gboolean end;
- - GError *error = NULL;
- - prv_new_device_ct_t *priv_t = (prv_new_device_ct_t *)user_data;
- + g_autofree gchar *result = NULL;
- + g_autoptr(GError) error = NULL;
- + dleyna_gasync_task_t *task = user_data;
- + prv_new_device_ct_t *priv_t =
- + (prv_new_device_ct_t *) dleyna_gasync_task_get_user_data(task);
- + g_autoptr(GUPnPServiceProxyAction) action;
-
- - priv_t->dev->construct_step++;
- - end = gupnp_service_proxy_end_action(proxy, action, &error,
- - "SortExtensionCaps",
- - G_TYPE_STRING, &result, NULL);
- + action = gupnp_service_proxy_call_action_finish(
- + GUPNP_SERVICE_PROXY(source), res, &error);
-
- - if (!end || (result == NULL)) {
- - DLEYNA_LOG_WARNING(
- - "GetSortExtensionCapabilities operation failed: %s",
- - ((error != NULL) ? error->message : "Invalid result"));
- - goto on_error;
- + g_print("Sort ext\n");
- +
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- }
-
- - DLEYNA_LOG_DEBUG("GetSortExtensionCapabilities result: %s", result);
- + priv_t->dev->construct_step++;
-
- - prv_get_sort_ext_capabilities_analyze(priv_t->dev, result);
- + if (error == NULL) {
- + gupnp_service_proxy_action_get_result(action, &error, "SortCaps",
- + G_TYPE_STRING, &result, NULL);
- + }
-
- -on_error:
- + if (error!= NULL) {
- + DLEYNA_LOG_WARNING("GetSortCapabilitiesExt operation failed: %s",
- + error->message);
-
- - if (error)
- - g_error_free(error);
- + } else {
- + DLEYNA_LOG_DEBUG("GetSortCapabilities result: %s", result);
-
- - g_free(result);
- + prv_get_sort_ext_capabilities_analyze(priv_t->dev, result);
- + }
- +
- + dleyna_task_queue_task_completed (((dleyna_task_atom_t *) task)->queue_id);
- }
-
- -static GUPnPServiceProxyAction *prv_get_sort_ext_capabilities(
- - dleyna_service_task_t *task,
- - GUPnPServiceProxy *proxy,
- - gboolean *failed)
- -{
- - *failed = FALSE;
- -
- - return gupnp_service_proxy_begin_action(
- - proxy,
- - "GetSortExtensionCapabilities",
- - dleyna_service_task_begin_action_cb,
- - task, NULL);
- +static gboolean prv_get_sort_ext_capabilities(dleyna_gasync_task_t *task,
- + GObject *target)
- +{
- + GUPnPServiceProxyAction *action =
- + gupnp_service_proxy_action_new("GetSortExtensionCapabilities", NULL);
- + gupnp_service_proxy_call_action_async(
- + GUPNP_SERVICE_PROXY(target), action,
- + dleyna_gasync_task_get_cancellable(task),
- + prv_get_sort_ext_capabilities_cb, task);
- +
- + return FALSE;
- }
-
- static void prv_get_capabilities_analyze(GHashTable *property_map,
- @@ -1405,117 +1416,125 @@
- #endif
- }
-
- -static void prv_get_sort_capabilities_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- +static void prv_get_sort_capabilities_cb(GObject *source,
- + GAsyncResult *res,
- gpointer user_data)
- {
- - gchar *result = NULL;
- - gboolean end;
- - GError *error = NULL;
- - prv_new_device_ct_t *priv_t = (prv_new_device_ct_t *)user_data;
- + g_autofree gchar *result = NULL;
- + g_autoptr(GError) error = NULL;
- + dleyna_gasync_task_t *task = user_data;
- + prv_new_device_ct_t *priv_t = (prv_new_device_ct_t *) dleyna_gasync_task_get_user_data(task);
- + g_autoptr(GUPnPServiceProxyAction) action;
- +
- + action = gupnp_service_proxy_call_action_finish(
- + GUPNP_SERVICE_PROXY(source), res, &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- priv_t->dev->construct_step++;
- - end = gupnp_service_proxy_end_action(proxy, action, &error, "SortCaps",
- - G_TYPE_STRING, &result, NULL);
-
- - if (!end || (result == NULL)) {
- - DLEYNA_LOG_WARNING("GetSortCapabilities operation failed: %s",
- - ((error != NULL) ? error->message
- - : "Invalid result"));
- - goto on_error;
- + if (error == NULL) {
- + gupnp_service_proxy_action_get_result(action, &error, "SortCaps",
- + G_TYPE_STRING, &result, NULL);
- }
-
- - DLEYNA_LOG_DEBUG("GetSortCapabilities result: %s", result);
- -
- - prv_get_capabilities_analyze(priv_t->property_map, result,
- - &priv_t->dev->sort_caps);
- + if (error!= NULL) {
- + DLEYNA_LOG_WARNING("GetSortCapabilities operation failed: %s",
- + error->message);
-
- -on_error:
- + } else {
- + DLEYNA_LOG_DEBUG("GetSortCapabilities result: %s", result);
-
- - if (error)
- - g_error_free(error);
- + prv_get_capabilities_analyze(priv_t->property_map, result,
- + &priv_t->dev->sort_caps);
- + }
-
- - g_free(result);
- + dleyna_task_queue_task_completed (((dleyna_task_atom_t *) task)->queue_id);
- }
-
- -static GUPnPServiceProxyAction *prv_get_sort_capabilities(
- - dleyna_service_task_t *task,
- - GUPnPServiceProxy *proxy,
- - gboolean *failed)
- -{
- - *failed = FALSE;
- -
- - return gupnp_service_proxy_begin_action(
- - proxy,
- - "GetSortCapabilities",
- - dleyna_service_task_begin_action_cb,
- - task, NULL);
- +static gboolean prv_get_sort_capabilities(dleyna_gasync_task_t *task,
- + GObject *target)
- +{
- + GUPnPServiceProxyAction *action =
- + gupnp_service_proxy_action_new("GetSortCapabilities", NULL);
- + gupnp_service_proxy_call_action_async(
- + GUPNP_SERVICE_PROXY(target), action,
- + dleyna_gasync_task_get_cancellable(task),
- + prv_get_sort_capabilities_cb, task);
- +
- + return FALSE;
- }
-
- -static void prv_get_search_capabilities_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- +static void prv_get_search_capabilities_cb(GObject *source,
- + GAsyncResult *res,
- gpointer user_data)
- {
- - gchar *result = NULL;
- - gboolean end;
- - GError *error = NULL;
- - prv_new_device_ct_t *priv_t = (prv_new_device_ct_t *)user_data;
- + g_autofree gchar *result = NULL;
- + g_autoptr(GError) error = NULL;
- + dleyna_gasync_task_t *task = user_data;
- + prv_new_device_ct_t *priv_t =
- + (prv_new_device_ct_t *) dleyna_gasync_task_get_user_data(task);
- +
- + g_autoptr(GUPnPServiceProxyAction) action =
- + gupnp_service_proxy_call_action_finish(
- + GUPNP_SERVICE_PROXY(source), res, &error);
- +
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
- +
- + if (error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error, "SearchCaps", G_TYPE_STRING, &result,
- + NULL);
- + }
-
- priv_t->dev->construct_step++;
- - end = gupnp_service_proxy_end_action(proxy, action, &error,
- - "SearchCaps", G_TYPE_STRING,
- - &result, NULL);
- -
- - if (!end || (result == NULL)) {
- + if (error != NULL) {
- DLEYNA_LOG_WARNING("GetSearchCapabilities operation failed: %s",
- - ((error != NULL) ? error->message
- - : "Invalid result"));
- - goto on_error;
- - }
- + error->message);
-
- - DLEYNA_LOG_DEBUG("GetSearchCapabilities result: %s", result);
- + } else {
- + DLEYNA_LOG_DEBUG("GetSearchCapabilities result: %s", result);
-
- - prv_get_capabilities_analyze(priv_t->property_map, result,
- - &priv_t->dev->search_caps);
- + prv_get_capabilities_analyze(priv_t->property_map, result,
- + &priv_t->dev->search_caps);
-
- - if (g_hash_table_lookup(priv_t->property_map, "upnp:objectUpdateID"))
- - priv_t->dev->has_last_change = TRUE;
- + if(g_hash_table_lookup(priv_t->property_map,
- + "upnp:objectUpdateID"))
- + priv_t->dev->has_last_change = TRUE;
- + }
-
- -on_error:
- + dleyna_task_queue_task_completed (((dleyna_task_atom_t *) task)->queue_id);
- +}
-
- - if (error)
- - g_error_free(error);
- +static gboolean prv_get_search_capabilities(
- + dleyna_gasync_task_t *task,
- + GObject *target)
- +{
- + GUPnPServiceProxyAction *action =
- + gupnp_service_proxy_action_new("GetSearchCapabilities", NULL);
-
- - g_free(result);
- + gupnp_service_proxy_call_action_async(
- + GUPNP_SERVICE_PROXY(target), action, dleyna_gasync_task_get_cancellable(task),
- + prv_get_search_capabilities_cb, task);
- +
- + return FALSE;
- }
-
- -static GUPnPServiceProxyAction *prv_get_search_capabilities(
- - dleyna_service_task_t *task,
- - GUPnPServiceProxy *proxy,
- - gboolean *failed)
- -{
- - *failed = FALSE;
- -
- - return gupnp_service_proxy_begin_action(
- - proxy, "GetSearchCapabilities",
- - dleyna_service_task_begin_action_cb,
- - task, NULL);
- -}
- -
- -static GUPnPServiceProxyAction *prv_subscribe(dleyna_service_task_t *task,
- - GUPnPServiceProxy *proxy,
- - gboolean *failed)
- +static gboolean prv_subscribe(dleyna_gasync_task_t *task, GObject *target)
- {
- dls_device_t *device;
-
- - device = (dls_device_t *)dleyna_service_task_get_user_data(task);
- + device = (dls_device_t *)dleyna_gasync_task_get_user_data(task);
-
- device->construct_step++;
- dls_device_subscribe_to_service_changes(device);
-
- - *failed = FALSE;
- + dleyna_task_queue_task_completed (((dleyna_task_atom_t *) task)->queue_id);
-
- - return NULL;
- + return FALSE;
- }
-
- static gboolean prv_subtree_interface_filter(const gchar *object_path,
- @@ -1553,15 +1572,13 @@
- return retval;
- }
-
- -static GUPnPServiceProxyAction *prv_declare(dleyna_service_task_t *task,
- - GUPnPServiceProxy *proxy,
- - gboolean *failed)
- +static gboolean prv_declare(dleyna_gasync_task_t *task, GObject *target)
- {
- guint id;
- dls_device_t *device;
- prv_new_device_ct_t *priv_t;
-
- - priv_t = (prv_new_device_ct_t *)dleyna_service_task_get_user_data(task);
- + priv_t = (prv_new_device_ct_t *)dleyna_gasync_task_get_user_data(task);
- device = priv_t->dev;
- device->construct_step++;
-
- @@ -1588,9 +1605,9 @@
- DLEYNA_LOG_WARNING("dleyna_connector_publish_subtree FAILED");
- }
-
- - *failed = (!id);
- + dleyna_task_queue_task_completed (((dleyna_task_atom_t *) task)->queue_id);
-
- - return NULL;
- + return !id;
- }
-
- void dls_device_construct(
- @@ -1614,36 +1631,39 @@
- priv_t->property_map = property_map;
-
- s_proxy = context->cds.proxy;
- + GCancellable *cancellable = g_cancellable_new();
-
- if (dev->construct_step < 1)
- - dleyna_service_task_add(queue_id, prv_get_search_capabilities,
- - s_proxy,
- - prv_get_search_capabilities_cb, NULL,
- + dleyna_gasync_task_add(queue_id,
- + prv_get_search_capabilities,
- + G_OBJECT(s_proxy),
- + cancellable,
- + NULL,
- priv_t);
-
- if (dev->construct_step < 2)
- - dleyna_service_task_add(queue_id, prv_get_sort_capabilities,
- - s_proxy,
- - prv_get_sort_capabilities_cb, NULL,
- - priv_t);
- + dleyna_gasync_task_add(queue_id, prv_get_sort_capabilities,
- + G_OBJECT(s_proxy), cancellable, NULL,
- + priv_t);
-
- if (dev->construct_step < 3)
- - dleyna_service_task_add(queue_id, prv_get_sort_ext_capabilities,
- - s_proxy,
- - prv_get_sort_ext_capabilities_cb, NULL,
- + dleyna_gasync_task_add(queue_id, prv_get_sort_ext_capabilities,
- + G_OBJECT(s_proxy),
- + cancellable, NULL,
- priv_t);
-
- if (dev->construct_step < 4)
- - dleyna_service_task_add(queue_id, prv_get_feature_list, s_proxy,
- - prv_get_feature_list_cb, NULL, priv_t);
- + dleyna_gasync_task_add(queue_id, prv_get_feature_list,
- + G_OBJECT(s_proxy), cancellable, NULL,
- + priv_t);
-
- /* The following task should always be completed */
- - dleyna_service_task_add(queue_id, prv_subscribe, s_proxy,
- - NULL, NULL, dev);
- + dleyna_gasync_task_add(queue_id, prv_subscribe, G_OBJECT(s_proxy),
- + cancellable, NULL, dev);
-
- if (dev->construct_step < 6)
- - dleyna_service_task_add(queue_id, prv_declare, s_proxy,
- - NULL, g_free, priv_t);
- + dleyna_gasync_task_add(queue_id, prv_declare, G_OBJECT(s_proxy),
- + cancellable, g_free, priv_t);
-
- dleyna_task_queue_start(queue_id);
- }
- @@ -1885,32 +1905,35 @@
- cb_task_data->get_children_cb(cb_data);
- }
-
- -static void prv_get_children_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_get_children_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - gchar *result = NULL;
- - const gchar *message;
- - gboolean end;
- - GUPnPDIDLLiteParser *parser = NULL;
- - GError *error = NULL;
- + g_autofree char *result = NULL;
- + g_autoptr(GUPnPDIDLLiteParser) parser = NULL;
- + g_autoptr(GError) error = NULL;
- dls_async_task_t *cb_data = user_data;
- dls_async_bas_t *cb_task_data = &cb_data->ut.bas;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - &error, "Result",
- - G_TYPE_STRING, &result, NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - if (!end || (result == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- - DLEYNA_LOG_WARNING("Browse operation failed: %s", message);
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error, "Result", G_TYPE_STRING, &result, NULL);
- + }
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Browse operation failed: %s",
- - message);
- + if(error != NULL) {
- + DLEYNA_LOG_WARNING("Browse operation failed: %s",
- + error->message);
- +
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Browse operation failed: %s", error->message);
- goto on_error;
- }
-
- @@ -1949,18 +1972,8 @@
- on_error:
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
-
- no_complete:
- -
- - if (error)
- - g_error_free(error);
- -
- - if (parser)
- - g_object_unref(parser);
- -
- - g_free(result);
- -
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- @@ -1980,27 +1993,22 @@
- g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->action =
- - gupnp_service_proxy_begin_action(cb_data->proxy,
- - "Browse",
- - prv_get_children_cb,
- - cb_data,
- - "ObjectID", G_TYPE_STRING,
- - task->target.id,
- -
- - "BrowseFlag", G_TYPE_STRING,
- - "BrowseDirectChildren",
- -
- - "Filter", G_TYPE_STRING,
- - upnp_filter,
- -
- - "StartingIndex", G_TYPE_INT,
- - task->ut.get_children.start,
- - "RequestedCount", G_TYPE_INT,
- - task->ut.get_children.count,
- - "SortCriteria", G_TYPE_STRING,
- - sort_by,
- - NULL);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "Browse", "ObjectID", G_TYPE_STRING, task->target.id,
- +
- + "BrowseFlag", G_TYPE_STRING, "BrowseDirectChildren",
- +
- + "Filter", G_TYPE_STRING, upnp_filter,
- +
- + "StartingIndex", G_TYPE_INT, task->ut.get_children.start,
- + "RequestedCount", G_TYPE_INT, task->ut.get_children.count,
- + "SortCriteria", G_TYPE_STRING, sort_by, NULL);
- +
- + gupnp_service_proxy_call_action_async(cb_data->proxy,
- + cb_data->action,
- + cb_data->cancellable,
- + prv_get_children_cb,
- + cb_data);
-
- cb_data->cancel_id = g_cancellable_connect(
- cb_data->cancellable,
- @@ -2142,32 +2150,34 @@
- return subscribed;
- }
-
- -static void prv_system_update_id_for_prop_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_system_update_id_for_prop_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *error = NULL;
- - const gchar *message;
- - gboolean end;
- + g_autoptr(GError) error = NULL;
- guint id = G_MAXUINT32;
- dls_async_task_t *cb_data = user_data;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(proxy, action, &error,
- - "Id", G_TYPE_UINT, &id, NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
- +
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(action, &error, "Id",
- + G_TYPE_UINT, &id, NULL);
- + }
-
- - if (!end || (id == G_MAXUINT32)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- + if(error != NULL) {
- DLEYNA_LOG_WARNING("Unable to retrieve SystemUpdateID: %s",
- - message);
- + error->message);
-
- cb_data->error = g_error_new(
- - DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Unable to retrieve SystemUpdateID: %s",
- - message);
- -
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Unable to retrieve SystemUpdateID: %s",
- + error->message);
- goto on_complete;
- }
-
- @@ -2176,10 +2186,6 @@
- on_complete:
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
- -
- - if (error)
- - g_error_free(error);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -2203,51 +2209,51 @@
- goto on_complete;
- }
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - proxy, "GetSystemUpdateID",
- - prv_system_update_id_for_prop_cb,
- - cb_data,
- - NULL);
- + cb_data->action = gupnp_service_proxy_action_new("GetSystemUpdateID", NULL);
-
- cb_data->proxy = proxy;
- g_object_add_weak_pointer((G_OBJECT(proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- + gupnp_service_proxy_call_action_async(
- + proxy, cb_data->action, cb_data->cancellable,
- + prv_system_update_id_for_prop_cb, cb_data);
-
- on_complete:
-
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- -static void prv_system_update_id_for_props_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_system_update_id_for_props_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *error = NULL;
- - const gchar *message;
- - gboolean end;
- + g_autoptr(GError) error = NULL;
- guint id = G_MAXUINT32;
- dls_async_task_t *cb_data = user_data;
- dls_async_get_all_t *cb_task_data = &cb_data->ut.get_all;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
- +
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(proxy, action, &error,
- - "Id", G_TYPE_UINT, &id, NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - if (!end || (id == G_MAXUINT32)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(action, &error, "Id",
- + G_TYPE_UINT, &id, NULL);
- + }
- +
- + if(error != NULL) {
- DLEYNA_LOG_WARNING("Unable to retrieve SystemUpdateID: %s",
- - message);
- + error->message);
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Unable to retrieve SystemUpdateID: %s",
- - message);
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Unable to retrieve SystemUpdateID: %s",
- + error->message);
-
- goto on_complete;
- }
- @@ -2259,19 +2265,14 @@
- on_complete:
-
- if (!cb_data->error)
- - prv_get_sr_token_for_props(proxy, cb_data->task.target.device,
- + prv_get_sr_token_for_props(GUPNP_SERVICE_PROXY (source), cb_data->task.target.device,
- cb_data);
- else {
- cb_data->task.result = g_variant_ref_sink(g_variant_builder_end(
- cb_task_data->vb));
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable,
- - cb_data->cancel_id);
- }
-
- - if (error)
- - g_error_free(error);
- -
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- @@ -2298,11 +2299,8 @@
- goto on_complete;
- }
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - proxy, "GetSystemUpdateID",
- - prv_system_update_id_for_props_cb,
- - cb_data,
- - NULL);
- + cb_data->action =
- + gupnp_service_proxy_action_new("GetSystemUpdateID", NULL);
-
- if (cb_data->proxy != NULL)
- g_object_remove_weak_pointer((G_OBJECT(cb_data->proxy)),
- @@ -2310,15 +2308,13 @@
-
- cb_data->proxy = proxy;
-
- + gupnp_service_proxy_call_action_async(
- + proxy, cb_data->action, cb_data->cancellable,
- + prv_system_update_id_for_props_cb, cb_data);
- +
- g_object_add_weak_pointer((G_OBJECT(proxy)),
- (gpointer *)&cb_data->proxy);
-
- - if (!cb_data->cancel_id)
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- -
- on_complete:
-
- DLEYNA_LOG_DEBUG("Exit");
- @@ -2341,34 +2337,36 @@
- return subscribed;
- }
-
- -static void prv_sleeping_for_props_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_sleeping_for_props_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *error = NULL;
- - const gchar *message;
- - gchar *info = NULL;
- - gboolean end;
- + g_autoptr(GError) error = NULL;
- + g_autofree gchar *info = NULL;
- dls_async_task_t *cb_data = user_data;
- dls_async_get_all_t *cb_task_data;
- gboolean sleeping;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(proxy, action, &error,
- - "NetworkInterfaceInfo",
- - G_TYPE_STRING,
- - &info, NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - if (!end || (info == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error, "NetworkInterfaceInfo", G_TYPE_STRING,
- + &info, NULL);
- + }
- +
- + if (error != NULL) {
- DLEYNA_LOG_WARNING("NetworkInterfaceInfo retrieval failed: %s",
- - message);
- + error->message);
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "GetInterfaceInfo failed: %s",
- - message);
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "GetInterfaceInfo failed: %s", error->message);
- goto on_complete;
- }
-
- @@ -2384,15 +2382,9 @@
- cb_task_data->vb));
- }
-
- - g_free(info);
- -
- on_complete:
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
- -
- - if (error)
- - g_error_free(error);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -2421,27 +2413,25 @@
- goto on_complete;
- }
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - proxy, "GetInterfaceInfo",
- - prv_sleeping_for_props_cb,
- - cb_data,
- - NULL);
-
- if (cb_data->proxy != NULL)
- g_object_remove_weak_pointer((G_OBJECT(cb_data->proxy)),
- (gpointer *)&cb_data->proxy);
-
- + cb_data->action = gupnp_service_proxy_action_new ("GetInterfaceInfo", NULL);
- +
- +
- +
- cb_data->proxy = proxy;
-
- g_object_add_weak_pointer((G_OBJECT(proxy)),
- (gpointer *)&cb_data->proxy);
-
- - if (!cb_data->cancel_id)
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- -
- + gupnp_service_proxy_call_action_async(
- + proxy, cb_data->action,
- + cb_data->cancellable,
- + prv_sleeping_for_props_cb,
- + cb_data);
- return;
-
- on_complete:
- @@ -2476,31 +2466,34 @@
- return -1;
- }
-
- -static void prv_service_reset_for_prop_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_service_reset_for_prop_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *error = NULL;
- - const gchar *message;
- - gchar *token = NULL;
- - gboolean end;
- + g_autoptr(GError) error = NULL;
- + g_autofree gchar *token = NULL;
- dls_async_task_t *cb_data = user_data;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(proxy, action, &error,
- - "ResetToken", G_TYPE_STRING,
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
- +
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error,"ResetToken", G_TYPE_STRING,
- &token, NULL);
- + }
-
- - if (!end || (token == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- + if (error != NULL) {
- DLEYNA_LOG_WARNING("Unable to retrieve ServiceResetToken: %s",
- - message);
- + error->message);
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "GetServiceResetToken failed: %s",
- - message);
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "GetServiceResetToken failed: %s", error->message);
-
- goto on_complete;
- }
- @@ -2509,15 +2502,9 @@
-
- DLEYNA_LOG_DEBUG("Service Reset %s", token);
-
- - g_free(token);
- -
- on_complete:
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
- -
- - if (error)
- - g_error_free(error);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -2538,65 +2525,59 @@
- goto on_error;
- }
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - proxy, "GetServiceResetToken",
- - prv_service_reset_for_prop_cb,
- - cb_data,
- - NULL);
-
- cb_data->proxy = proxy;
- g_object_add_weak_pointer((G_OBJECT(proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- + cb_data->action = gupnp_service_proxy_action_new("GetServiceResetToken", NULL);
- +
- + gupnp_service_proxy_call_action_async(
- + proxy, cb_data->action, cb_data->cancellable,
- + prv_service_reset_for_prop_cb, cb_data);
-
- on_error:
-
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- -static void prv_service_reset_for_props_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_service_reset_for_props_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *error = NULL;
- - const gchar *message;
- - gchar *token = NULL;
- - gboolean end;
- + g_autoptr(GError) error = NULL;
- + g_autofree gchar *token = NULL;
- dls_async_task_t *cb_data = user_data;
- dls_async_get_all_t *cb_task_data;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- cb_task_data = &cb_data->ut.get_all;
-
- - end = gupnp_service_proxy_end_action(proxy, action, &error,
- - "ResetToken", G_TYPE_STRING,
- - &token, NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error,"ResetToken", G_TYPE_STRING,
- + &token, NULL);
- + }
-
- - if (!end || (token == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- + if (error != NULL) {
- DLEYNA_LOG_WARNING("Unable to retrieve ServiceResetToken: %s",
- - message);
- + error->message);
- +
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "GetServiceResetToken failed: %s", error->message);
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "GetServiceResetToken failed: %s",
- - message);
- goto on_complete;
- }
-
- - g_variant_builder_add(cb_task_data->vb, "{sv}",
- - DLS_INTERFACE_PROP_SV_SERVICE_RESET_TOKEN,
- - g_variant_new_string(token));
-
- DLEYNA_LOG_DEBUG("Service Reset %s", token);
-
- - g_free(token);
- -
- on_complete:
-
- if ((!cb_data->error) && (cb_task_data->proxy))
- @@ -2608,13 +2589,8 @@
- cb_task_data->vb));
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable,
- - cb_data->cancel_id);
- }
-
- - if (error)
- - g_error_free(error);
- -
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- @@ -2635,11 +2611,6 @@
- goto on_exit; /* No error here, just skip the property */
- }
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - proxy, "GetServiceResetToken",
- - prv_service_reset_for_props_cb,
- - cb_data,
- - NULL);
-
- if (cb_data->proxy != NULL)
- g_object_remove_weak_pointer((G_OBJECT(cb_data->proxy)),
- @@ -2649,11 +2620,10 @@
- g_object_add_weak_pointer((G_OBJECT(proxy)),
- (gpointer *)&cb_data->proxy);
-
- - if (!cb_data->cancel_id)
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- + cb_data->action = gupnp_service_proxy_action_new("GetServiceResetToken", NULL);
- + gupnp_service_proxy_call_action_async(
- + proxy, cb_data->action, cb_data->cancellable,
- + prv_service_reset_for_props_cb, cb_data);
-
- on_exit:
-
- @@ -2662,34 +2632,36 @@
- return;
- }
-
- -static void prv_sleeping_for_prop_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_sleeping_for_prop_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *error = NULL;
- - const gchar *message;
- - gchar *info = NULL;
- - gboolean end;
- + g_autoptr(GError) error = NULL;
- + g_autofree gchar *info = NULL;
- dls_async_task_t *cb_data = user_data;
- gboolean sleeping;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
- +
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(proxy, action, &error,
- - "NetworkInterfaceInfo",
- - G_TYPE_STRING,
- - &info, NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - if (!end || (info == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- - DLEYNA_LOG_WARNING("NetworkInterfaceInfo retrieval failed: %s",
- - message);
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error, "NetworkInterfaceInfo", G_TYPE_STRING,
- + &info, NULL);
- + }
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "GetInterfaceInfo failed: %s",
- - message);
- + if (error != NULL) {
- + DLEYNA_LOG_WARNING("NetworkInterfaceInfo retrieval failed: %s",
- + error->message);
-
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "GetInterfaceInfo failed: %s", error->message);
- goto on_complete;
- }
-
- @@ -2700,15 +2672,9 @@
- g_variant_new_boolean(sleeping));
- }
-
- - g_free(info);
- -
- on_complete:
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
- -
- - if (error)
- - g_error_free(error);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -2740,21 +2706,17 @@
- goto on_complete;
- }
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - proxy, "GetInterfaceInfo",
- - prv_sleeping_for_prop_cb,
- - cb_data,
- - NULL);
- -
- cb_data->proxy = proxy;
-
- g_object_add_weak_pointer((G_OBJECT(proxy)),
- - (gpointer *)&cb_data->proxy);
- + (gpointer *) &cb_data->proxy);
- +
- + cb_data->action =
- + gupnp_service_proxy_action_new("GetInterfaceInfo", NULL);
- + gupnp_service_proxy_call_action_async(
- + proxy, cb_data->action, cb_data->cancellable,
- + prv_sleeping_for_prop_cb, cb_data);
-
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- on_complete:
-
- DLEYNA_LOG_DEBUG("Exit");
- @@ -2777,32 +2739,35 @@
- return !cb_task_data->device_object;
- }
-
- -static void prv_get_all_ms2spec_props_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_get_all_ms2spec_props_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *error = NULL;
- - const gchar *message;
- - gchar *result = NULL;
- - gboolean end;
- - GUPnPDIDLLiteParser *parser = NULL;
- + g_autoptr(GError) error = NULL;
- + g_autofree gchar *result = NULL;
- + g_autoptr(GUPnPDIDLLiteParser) parser = NULL;
- dls_async_task_t *cb_data = user_data;
- dls_async_get_all_t *cb_task_data = &cb_data->ut.get_all;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - &error, "Result",
- - G_TYPE_STRING, &result, NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - if (!end || (result == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- - DLEYNA_LOG_WARNING("Browse operation failed: %s", message);
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error, "Result", G_TYPE_STRING, &result, NULL);
- + }
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Browse operation failed: %s",
- - message);
- + if(error != NULL) {
- + DLEYNA_LOG_WARNING("Browse operation failed: %s",
- + error->message);
- +
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Browse operation failed: %s", error->message);
- goto on_error;
- }
-
- @@ -2847,7 +2812,7 @@
- goto no_complete;
- } else if (cb_data->task.type == DLS_TASK_GET_ALL_PROPS &&
- cb_task_data->device_object) {
- - prv_get_system_update_id_for_props(proxy,
- + prv_get_system_update_id_for_props(GUPNP_SERVICE_PROXY(source),
- cb_data->task.target.device,
- cb_data);
-
- @@ -2860,18 +2825,8 @@
- on_error:
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
-
- no_complete:
- -
- - if (error)
- - g_error_free(error);
- -
- - if (parser)
- - g_object_unref(parser);
- -
- - g_free(result);
- -
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- @@ -2904,27 +2859,22 @@
- goto on_error;
- }
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - context->cds.proxy, "Browse",
- - prv_get_all_ms2spec_props_cb, cb_data,
- - "ObjectID", G_TYPE_STRING, task->target.id,
- - "BrowseFlag", G_TYPE_STRING, "BrowseMetadata",
- - "Filter", G_TYPE_STRING, "*",
- - "StartingIndex", G_TYPE_INT, 0,
- - "RequestedCount", G_TYPE_INT, 0,
- - "SortCriteria", G_TYPE_STRING,
- - "", NULL);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "Browse", "ObjectID", G_TYPE_STRING, task->target.id,
- + "BrowseFlag", G_TYPE_STRING, "BrowseMetadata", "Filter",
- + G_TYPE_STRING, "*", "StartingIndex", G_TYPE_INT, 0,
- + "RequestedCount", G_TYPE_INT, 0, "SortCriteria", G_TYPE_STRING,
- + "", NULL);
- +
- + gupnp_service_proxy_call_action_async(
- + context->cds.proxy, cb_data->action, cb_data->cancellable,
- + prv_get_all_ms2spec_props_cb, cb_data);
-
- cb_data->proxy = context->cds.proxy;
-
- g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- -
- DLEYNA_LOG_DEBUG("Exit with SUCCESS");
-
- return;
- @@ -3096,33 +3046,34 @@
- return TRUE;
- }
-
- -static void prv_count_children_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- -{
- +static void prv_count_children_cb(GObject *source, GAsyncResult *res, gpointer user_data){
- dls_device_count_data_t *count_data = user_data;
- dls_async_task_t *cb_data = count_data->cb_data;
- - GError *error = NULL;
- - const gchar *message;
- + g_autoptr(GError) error = NULL;
- guint count = G_MAXUINT32;
- gboolean complete = FALSE;
- - gboolean end;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - &error,
- - "TotalMatches", G_TYPE_UINT, &count,
- - NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - if (!end || (count == G_MAXUINT32)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- - DLEYNA_LOG_WARNING("Browse operation failed: %s", message);
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(action, &error, "TotalMatches",
- + G_TYPE_UINT, &count, NULL);
- + }
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Browse operation failed: %s",
- - message);
- + if(error != NULL) {
- + DLEYNA_LOG_WARNING("Browse operation failed: %s",
- + error->message);
- +
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Browse operation failed: %s", error->message);
- goto on_error;
- }
-
- @@ -3134,13 +3085,8 @@
-
- if (cb_data->error || complete) {
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable,
- - cb_data->cancel_id);
- }
-
- - if (error)
- - g_error_free(error);
- -
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- @@ -3152,62 +3098,59 @@
- DLEYNA_LOG_DEBUG("Enter");
-
- prv_count_data_new(cb_data, cb, &count_data);
- - cb_data->action =
- - gupnp_service_proxy_begin_action(cb_data->proxy,
- - "Browse",
- - prv_count_children_cb,
- - count_data,
- - "ObjectID", G_TYPE_STRING, id,
- -
- - "BrowseFlag", G_TYPE_STRING,
- - "BrowseDirectChildren",
- + cb_data->action = gupnp_service_proxy_action_new(
- + "Browse", "ObjectID", G_TYPE_STRING, id,
-
- - "Filter", G_TYPE_STRING, "",
- + "BrowseFlag", G_TYPE_STRING, "BrowseDirectChildren",
-
- - "StartingIndex", G_TYPE_INT,
- - 0,
- + "Filter", G_TYPE_STRING, "",
-
- - "RequestedCount", G_TYPE_INT,
- - 1,
- + "StartingIndex", G_TYPE_INT, 0,
-
- - "SortCriteria", G_TYPE_STRING,
- - "",
- + "RequestedCount", G_TYPE_INT, 1,
-
- - NULL);
- + "SortCriteria", G_TYPE_STRING, "", NULL);
-
- + gupnp_service_proxy_call_action_async(
- + cb_data->proxy, cb_data->action, cb_data->cancellable,
- + prv_count_children_cb, count_data);
- DLEYNA_LOG_DEBUG("Exit with SUCCESS");
- }
-
- -static void prv_get_ms2spec_prop_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_get_ms2spec_prop_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *error = NULL;
- - const gchar *message;
- - gchar *result = NULL;
- - gboolean end;
- - GUPnPDIDLLiteParser *parser = NULL;
- + g_autoptr(GError) error = NULL;
- + g_autofree gchar *result = NULL;
- + g_autoptr(GUPnPDIDLLiteParser) parser = NULL;
- dls_async_task_t *cb_data = user_data;
- dls_async_get_prop_t *cb_task_data = &cb_data->ut.get_prop;
- dls_task_get_prop_t *task_data = &cb_data->task.ut.get_prop;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - &error, "Result",
- - G_TYPE_STRING, &result, NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - if (!end || (result == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- - DLEYNA_LOG_WARNING("Browse operation failed: %s", message);
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error, "Result", G_TYPE_STRING, &result, NULL);
- + }
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Browse operation failed: %s",
- - message);
- + if(error != NULL) {
- + DLEYNA_LOG_WARNING("Browse operation failed: %s",
- + error->message);
- +
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Browse operation failed: %s", error->message);
- goto on_error;
- }
-
- +
- DLEYNA_LOG_DEBUG("GetMS2SpecProp result: %s", result);
-
- parser = gupnp_didl_lite_parser_new();
- @@ -3257,18 +3200,8 @@
- cb_data->task.target.id);
- } else {
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable,
- - cb_data->cancel_id);
- }
-
- - if (error)
- - g_error_free(error);
- -
- - if (parser)
- - g_object_unref(parser);
- -
- - g_free(result);
- -
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- @@ -3319,24 +3252,16 @@
- g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - cb_data->proxy, "Browse",
- - prv_get_ms2spec_prop_cb,
- - cb_data,
- - "ObjectID", G_TYPE_STRING, cb_data->task.target.id,
- - "BrowseFlag", G_TYPE_STRING,
- - "BrowseMetadata",
- - "Filter", G_TYPE_STRING, filter,
- - "StartingIndex", G_TYPE_INT, 0,
- - "RequestedCount", G_TYPE_INT, 0,
- - "SortCriteria", G_TYPE_STRING,
- - "",
- - NULL);
- -
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "Browse", "ObjectID", G_TYPE_STRING, cb_data->task.target.id,
- + "BrowseFlag", G_TYPE_STRING, "BrowseMetadata", "Filter",
- + G_TYPE_STRING, filter, "StartingIndex", G_TYPE_INT, 0,
- + "RequestedCount", G_TYPE_INT, 0, "SortCriteria", G_TYPE_STRING,
- + "", NULL);
- +
- + gupnp_service_proxy_call_action_async(cb_data->proxy, cb_data->action,
- + cb_data->cancellable,
- + prv_get_ms2spec_prop_cb, cb_data);
-
- DLEYNA_LOG_DEBUG("Exit with SUCCESS");
-
- @@ -3552,35 +3477,38 @@
- DLEYNA_LOG_DEBUG("Exit with FAIL");
- }
-
- -static void prv_search_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_search_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - gchar *result = NULL;
- - const gchar *message;
- - gboolean end;
- + g_autofree gchar *result = NULL;
- guint count = G_MAXUINT32;
- - GUPnPDIDLLiteParser *parser = NULL;
- - GError *error = NULL;
- + g_autoptr(GUPnPDIDLLiteParser) parser = NULL;
- + g_autoptr(GError) error = NULL;
- dls_async_task_t *cb_data = user_data;
- dls_async_bas_t *cb_task_data = &cb_data->ut.bas;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
- +
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - &error,
- - "Result", G_TYPE_STRING, &result,
- - "TotalMatches", G_TYPE_UINT,
- - &count, NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - if (!end || (result == NULL) || (count == G_MAXUINT32)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- - DLEYNA_LOG_WARNING("Search operation failed %s", message);
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error, "Result", G_TYPE_STRING, &result,
- + "TotalMatches", G_TYPE_UINT, &count, NULL);
- + }
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Search operation failed: %s",
- - message);
- + if(error != NULL) {
- + DLEYNA_LOG_WARNING("Search operation failed: %s",
- + error->message);
- +
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Search operation failed: %s", error->message);
- goto on_error;
- }
-
- @@ -3628,18 +3556,9 @@
- on_error:
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
-
- no_complete:
-
- - if (parser)
- - g_object_unref(parser);
- -
- - g_free(result);
- -
- - if (error)
- - g_error_free(error);
- -
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- @@ -3660,22 +3579,18 @@
- g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - cb_data->proxy, "Search",
- - prv_search_cb,
- - cb_data,
- - "ContainerID", G_TYPE_STRING, task->target.id,
- - "SearchCriteria", G_TYPE_STRING, upnp_query,
- - "Filter", G_TYPE_STRING, upnp_filter,
- - "StartingIndex", G_TYPE_INT, task->ut.search.start,
- - "RequestedCount", G_TYPE_INT, task->ut.search.count,
- - "SortCriteria", G_TYPE_STRING, sort_by,
- - NULL);
-
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "Search", "ContainerID", G_TYPE_STRING, task->target.id,
- + "SearchCriteria", G_TYPE_STRING, upnp_query, "Filter",
- + G_TYPE_STRING, upnp_filter, "StartingIndex", G_TYPE_INT,
- + task->ut.search.start, "RequestedCount", G_TYPE_INT,
- + task->ut.search.count, "SortCriteria", G_TYPE_STRING, sort_by,
- + NULL);
- +
- + gupnp_service_proxy_call_action_async(cb_data->proxy, cb_data->action,
- + cb_data->cancellable,
- + prv_search_cb, cb_data);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -3722,26 +3637,35 @@
- g_variant_builder_add(bo->avb, "@a{sv}", gv_result);
- }
-
- -static void prv_get_child_count_end_action_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- +static void prv_get_child_count_end_action_cb(GObject *source,
- + GAsyncResult *res,
- gpointer user_data)
- {
- - GError *error = NULL;
- - const gchar *message;
- + g_autoptr(GError) error = NULL;
- guint count = G_MAXUINT32;
- - gboolean end;
- + const char *message = NULL;
- dls_async_browse_objects_t *cb_task_data;
- - dls_async_task_t *cb_data = user_data;
- + dls_async_task_t *cb_data = dleyna_gasync_task_get_user_data(user_data);
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(proxy, action, &error,
- - "TotalMatches", G_TYPE_UINT,
- - &count, NULL);
- + action = gupnp_service_proxy_call_action_finish(
- + GUPNP_SERVICE_PROXY(source), res, &error);
-
- - cb_task_data = &((dls_async_task_t *)user_data)->ut.browse_objects;
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
- +
- + if (error == NULL) {
- + gupnp_service_proxy_action_get_result(action, &error,
- + "TotalMatches", G_TYPE_UINT,
- + &count, NULL);
- + }
-
- - if (!end || (count == G_MAXUINT32)) {
- + cb_task_data = &(cb_data)->ut.browse_objects;
- +
- + if (error != NULL || count == G_MAXUINT32) {
- message = (error != NULL) ? error->message : "Invalid result";
- DLEYNA_LOG_WARNING("Browse operation failed: %s", message);
-
- @@ -3777,34 +3701,29 @@
- }
-
- if (cb_task_data->index < cb_task_data->object_count)
- - dleyna_service_task_add(cb_task_data->queue_id,
- - prv_browse_objects_begin_action_cb,
- - proxy,
- - prv_browse_objects_end_action_cb,
- - NULL, user_data);
- -
- - if (error)
- - g_error_free(error);
- + dleyna_gasync_task_add(
- + cb_task_data->queue_id,
- + prv_browse_objects_begin_action_cb, source,
- + dleyna_gasync_task_get_user_data(user_data), NULL,
- + cb_data);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- -static GUPnPServiceProxyAction *prv_get_child_count_begin_action_cb(
- - dleyna_service_task_t *task,
- - GUPnPServiceProxy *proxy,
- - gboolean *failed)
- +static gboolean prv_get_child_count_begin_action_cb(dleyna_gasync_task_t *task,
- + GObject *target)
- {
- GUPnPServiceProxyAction *action;
- dls_task_t *user_data;
- const gchar *path;
- - gchar *root_path = NULL;
- - gchar *id = NULL;
- + g_autofree gchar *root_path = NULL;
- + g_autofree gchar *id = NULL;
- dls_async_browse_objects_t *cb_task_data;
- - GError *error = NULL;
- + g_autoptr(GError) error = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - user_data = (dls_task_t *)dleyna_service_task_get_user_data(task);
- + user_data = (dls_task_t *)dleyna_gasync_task_get_user_data(task);
- cb_task_data = &((dls_async_task_t *)user_data)->ut.browse_objects;
- path = cb_task_data->objects_id[cb_task_data->index - 1];
-
- @@ -3814,9 +3733,7 @@
- if (error != NULL)
- goto exit;
-
- - action = gupnp_service_proxy_begin_action(
- - proxy, "Browse",
- - dleyna_service_task_begin_action_cb, task,
- + action = gupnp_service_proxy_action_new ("Browse",
- "ObjectID", G_TYPE_STRING, id,
- "BrowseFlag", G_TYPE_STRING, "BrowseDirectChildren",
- "Filter", G_TYPE_STRING, "",
- @@ -3825,12 +3742,12 @@
- "SortCriteria", G_TYPE_STRING, "",
- NULL);
-
- - g_free(root_path);
- - g_free(id);
- + gupnp_service_proxy_call_action_async(
- + GUPNP_SERVICE_PROXY(target), action,
- + dleyna_gasync_task_get_cancellable(task),
- + prv_get_child_count_end_action_cb, task);
-
- exit:
- - *failed = FALSE;
- -
- if (error != NULL) {
- DLEYNA_LOG_WARNING("%s: %s", path, error->message);
- action = NULL;
- @@ -3843,46 +3760,51 @@
- }
-
- if (cb_task_data->index < cb_task_data->object_count)
- - dleyna_service_task_add(
- + dleyna_gasync_task_add(
- cb_task_data->queue_id,
- prv_browse_objects_begin_action_cb,
- - proxy,
- - prv_browse_objects_end_action_cb,
- + target,
- + dleyna_gasync_task_get_cancellable(task),
- NULL, user_data);
- - g_error_free(error);
- }
-
- - return action;
- + return FALSE;
- }
-
- -static void prv_browse_objects_end_action_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- +static void prv_browse_objects_end_action_cb(GObject *source,
- + GAsyncResult *res,
- gpointer user_data)
- {
- GError *error = NULL;
- - dls_async_task_t *cb_data = user_data;
- + dleyna_gasync_task_t *task = user_data;
- + dls_async_task_t *cb_data = dleyna_gasync_task_get_user_data(task);
- dls_async_browse_objects_t *cb_task_data = &cb_data->ut.browse_objects;
- dls_async_get_all_t *cb_all_data = &cb_data->ut.browse_objects.get_all;
- GUPnPDIDLLiteParser *parser = NULL;
- gchar *result = NULL;
- - const gchar *message;
- - gboolean end;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(proxy, action, &error,
- - "Result", G_TYPE_STRING, &result,
- - NULL);
- + g_autoptr(GUPnPServiceProxyAction) action;
-
- - if (!end || (result == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- + action = gupnp_service_proxy_call_action_finish(
- + GUPNP_SERVICE_PROXY(source), res, &error);
- +
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
- +
- + gupnp_service_proxy_action_get_result(action, &error, "Result",
- + G_TYPE_STRING, &result, NULL);
- +
- + if (error != NULL) {
- DLEYNA_LOG_WARNING("Browse Object operation failed: %s",
- - message);
- + error->message);
-
- cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- DLEYNA_ERROR_OPERATION_FAILED,
- "Browse operation failed: %s",
- - message);
- + error->message);
- goto on_exit;
- }
-
- @@ -3924,11 +3846,11 @@
- if (cb_all_data->need_child_count &&
- (cb_all_data->filter_mask & DLS_UPNP_MASK_PROP_CHILD_COUNT)) {
- DLEYNA_LOG_DEBUG("Need Child Count");
- - dleyna_service_task_add(cb_task_data->queue_id,
- - prv_get_child_count_begin_action_cb,
- - cb_data->proxy,
- - prv_get_child_count_end_action_cb,
- - NULL, cb_data);
- + dleyna_gasync_task_add(cb_task_data->queue_id,
- + prv_get_child_count_begin_action_cb,
- + G_OBJECT(cb_data->proxy),
- + dleyna_gasync_task_get_cancellable(task),
- + NULL, cb_data);
- goto no_complete;
- }
-
- @@ -3938,7 +3860,7 @@
- on_exit:
-
- if (cb_data->error != NULL) {
- - message = cb_task_data->objects_id[cb_task_data->index - 1];
- + const char *message = cb_task_data->objects_id[cb_task_data->index - 1];
- prv_browse_objects_add_error_result(cb_task_data, message,
- cb_data->error);
- g_error_free(cb_data->error);
- @@ -3951,11 +3873,11 @@
- }
-
- if (cb_task_data->index < cb_task_data->object_count)
- - dleyna_service_task_add(cb_task_data->queue_id,
- - prv_browse_objects_begin_action_cb,
- - cb_data->proxy,
- - prv_browse_objects_end_action_cb,
- - NULL, cb_data);
- + dleyna_gasync_task_add(cb_task_data->queue_id,
- + prv_browse_objects_begin_action_cb,
- + G_OBJECT(cb_data->proxy),
- + dleyna_gasync_task_get_cancellable(task),
- + NULL, cb_data);
- no_complete:
-
- if (parser)
- @@ -3969,10 +3891,8 @@
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- -static GUPnPServiceProxyAction *prv_browse_objects_begin_action_cb(
- - dleyna_service_task_t *task,
- - GUPnPServiceProxy *proxy,
- - gboolean *failed)
- +static gboolean prv_browse_objects_begin_action_cb(dleyna_gasync_task_t *task,
- + GObject *target)
- {
- GUPnPServiceProxyAction *action;
- dls_task_t *user_data;
- @@ -3984,7 +3904,7 @@
-
- DLEYNA_LOG_DEBUG("Enter called");
-
- - user_data = (dls_task_t *)dleyna_service_task_get_user_data(task);
- + user_data = (dls_task_t *)dleyna_gasync_task_get_user_data(task);
- cb_task_data = &((dls_async_task_t *)user_data)->ut.browse_objects;
- path = cb_task_data->objects_id[cb_task_data->index];
-
- @@ -3999,22 +3919,22 @@
-
- DLEYNA_LOG_DEBUG("Browse Metadata for path [id]: %s [%s]", path, id);
-
- - action = gupnp_service_proxy_begin_action(
- - proxy, "Browse",
- - dleyna_service_task_begin_action_cb, task,
- - "ObjectID", G_TYPE_STRING, id,
- - "BrowseFlag", G_TYPE_STRING, "BrowseMetadata",
- - "Filter", G_TYPE_STRING, cb_task_data->upnp_filter,
- - "StartingIndex", G_TYPE_INT, 0,
- - "RequestedCount", G_TYPE_INT, 0,
- - "SortCriteria", G_TYPE_STRING, "", NULL);
- + action = gupnp_service_proxy_action_new(
- + "Browse", "ObjectID", G_TYPE_STRING, id, "BrowseFlag",
- + G_TYPE_STRING, "BrowseMetadata", "Filter", G_TYPE_STRING,
- + cb_task_data->upnp_filter, "StartingIndex", G_TYPE_INT, 0,
- + "RequestedCount", G_TYPE_INT, 0, "SortCriteria", G_TYPE_STRING,
- + "", NULL);
- +
- + gupnp_service_proxy_call_action_async(
- + GUPNP_SERVICE_PROXY(target), action,
- + dleyna_gasync_task_get_cancellable(task),
- + prv_browse_objects_end_action_cb, task);
-
- g_free(root_path);
- g_free(id);
-
- exit:
- - *failed = FALSE;
- -
- /* It's the ONLY place where index is incremented */
- cb_task_data->index++;
-
- @@ -4026,28 +3946,14 @@
- g_error_free(error);
-
- if (cb_task_data->index < cb_task_data->object_count)
- - dleyna_service_task_add(
- - cb_task_data->queue_id,
- - prv_browse_objects_begin_action_cb,
- - proxy,
- - prv_browse_objects_end_action_cb,
- - NULL, user_data);
- + dleyna_gasync_task_add(
- + cb_task_data->queue_id,
- + prv_browse_objects_begin_action_cb, target,
- + dleyna_gasync_task_get_cancellable(task), NULL,
- + user_data);
- }
-
- - return action;
- -}
- -
- -static void prv_browse_objects_chain_cancelled(GCancellable *cancellable,
- - gpointer user_data)
- -{
- - dls_async_task_t *cb_data = user_data;
- -
- - DLEYNA_LOG_DEBUG("Enter");
- -
- - dleyna_task_processor_cancel_queue(cb_data->ut.browse_objects.queue_id);
- - dls_async_task_cancelled_cb(cancellable, user_data);
- -
- - DLEYNA_LOG_DEBUG("Exit");
- + return FALSE;
- }
-
- static void prv_browse_objects_chain_end(gboolean cancelled, gpointer data)
- @@ -4108,12 +4014,12 @@
-
- queue_id = dleyna_task_processor_add_queue(
- dls_server_get_task_processor(),
- - dleyna_service_task_create_source(),
- + dleyna_gasync_task_create_source(),
- DLS_SERVER_SINK,
- DLEYNA_TASK_QUEUE_FLAG_AUTO_REMOVE,
- - dleyna_service_task_process_cb,
- - dleyna_service_task_cancel_cb,
- - dleyna_service_task_delete_cb);
- + dleyna_gasync_task_process_cb,
- + dleyna_gasync_task_cancel_cb,
- + dleyna_gasync_task_delete_cb);
-
- dleyna_task_queue_set_finally(queue_id, prv_browse_objects_chain_end);
- dleyna_task_queue_set_user_data(queue_id, task);
- @@ -4130,16 +4036,9 @@
- g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(prv_browse_objects_chain_cancelled),
- - cb_data, NULL);
- -
- - dleyna_service_task_add(queue_id,
- - prv_browse_objects_begin_action_cb,
- - cb_data->proxy,
- - prv_browse_objects_end_action_cb,
- - NULL, cb_data);
- + dleyna_gasync_task_add(queue_id, prv_browse_objects_begin_action_cb,
- + G_OBJECT(cb_data->proxy), cb_data->cancellable, NULL,
- + cb_data);
-
- dleyna_task_queue_start(queue_id);
-
- @@ -4170,21 +4069,15 @@
- g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - cb_data->proxy, "Browse",
- - prv_get_all_ms2spec_props_cb, cb_data,
- - "ObjectID", G_TYPE_STRING, task->target.id,
- - "BrowseFlag", G_TYPE_STRING, "BrowseMetadata",
- - "Filter", G_TYPE_STRING, upnp_filter,
- - "StartingIndex", G_TYPE_INT, 0,
- - "RequestedCount", G_TYPE_INT, 0,
- - "SortCriteria", G_TYPE_STRING,
- - "", NULL);
- -
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "Browse", "ObjectID", G_TYPE_STRING, task->target.id,
- + "BrowseFlag", G_TYPE_STRING, "BrowseMetadata", "Filter",
- + G_TYPE_STRING, upnp_filter, "StartingIndex", G_TYPE_INT, 0,
- + "RequestedCount", G_TYPE_INT, 0, "SortCriteria", G_TYPE_STRING,
- + "", NULL);
- + gupnp_service_proxy_call_action_async(
- + cb_data->proxy, cb_data->action, cb_data->cancellable,
- + prv_get_all_ms2spec_props_cb, cb_data);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -4373,18 +4266,15 @@
- }
- }
-
- -static void prv_upload_delete_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_upload_delete_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- dls_async_task_t *cb_data = user_data;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - (void) gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - NULL, NULL);
- + gupnp_service_proxy_call_action_finish(cb_data->proxy, res, NULL);
- +
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -4447,18 +4337,25 @@
- NULL);
- }
-
- -static void prv_post_finished(SoupSession *session, SoupMessage *msg,
- +static void prv_post_finished(GObject *source, GAsyncResult *res,
- gpointer user_data)
- {
- dls_device_upload_job_t *upload_job = user_data;
- dls_device_upload_t *upload;
- gint *upload_id;
- + g_autoptr(GError) error = NULL;
- + g_autoptr(GBytes) data = NULL;
- + SoupMessage *msg = soup_session_get_async_result_message(
- + SOUP_SESSION(source), res);
-
- DLEYNA_LOG_DEBUG("Enter");
-
- DLEYNA_LOG_DEBUG("Upload %u finished. Code %u Message %s",
- - upload_job->upload_id, msg->status_code,
- - msg->reason_phrase);
- + upload_job->upload_id, soup_message_get_status(msg),
- + soup_message_get_reason_phrase (msg));
- +
- + data = soup_session_send_and_read_finish(SOUP_SESSION(source), res,
- + &error);
-
- /* This is clumsy but we need to distinguish between two cases:
- 1. We cancel because the process is exitting.
- @@ -4481,22 +4378,27 @@
- &upload_job->upload_id);
- if (upload) {
- upload_job->remove_idle =
- - g_timeout_add(30000, prv_remove_update_job, user_data);
- + g_timeout_add_seconds(30, prv_remove_update_job, user_data);
-
- - if (SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) {
- - upload->status = DLS_UPLOAD_STATUS_COMPLETED;
- - upload->bytes_uploaded = upload->bytes_to_upload;
- - } else if (msg->status_code == SOUP_STATUS_CANCELLED) {
- + // FIXME...
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- upload->status = DLS_UPLOAD_STATUS_CANCELLED;
- } else {
- - upload->status = DLS_UPLOAD_STATUS_ERROR;
- + SoupStatus status =
- + soup_message_get_status(upload->msg);
- + if(SOUP_STATUS_IS_SUCCESSFUL(status)) {
- + upload->status = DLS_UPLOAD_STATUS_COMPLETED;
- + upload->bytes_uploaded =
- + upload->bytes_to_upload;
- + } else {
- + upload->status = DLS_UPLOAD_STATUS_ERROR;
- + }
- }
-
- DLEYNA_LOG_DEBUG("Upload Status: %s", upload->status);
-
- prv_generate_upload_update(upload_job, upload);
-
- - g_object_unref(upload->msg);
- upload->msg = NULL;
-
- g_object_unref(upload->soup_session);
- @@ -4532,10 +4434,9 @@
-
- if (upload) {
- if (upload->msg) {
- - soup_session_cancel_message(upload->soup_session,
- - upload->msg,
- - SOUP_STATUS_CANCELLED);
- + g_cancellable_cancel(upload->cancellable);
- g_object_unref(upload->msg);
- + g_object_unref(upload->cancellable);
- }
-
- if (upload->soup_session)
- @@ -4552,12 +4453,12 @@
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- -static void prv_post_bytes_written(SoupMessage *msg, SoupBuffer *chunk,
- +static void prv_post_bytes_written(SoupMessage *msg, guint chunk_size,
- gpointer user_data)
- {
- dls_device_upload_t *upload = user_data;
-
- - upload->bytes_uploaded += chunk->length;
- + upload->bytes_uploaded += chunk_size;
- if (upload->bytes_uploaded > upload->bytes_to_upload)
- upload->bytes_uploaded = upload->bytes_to_upload;
- }
- @@ -4596,6 +4497,7 @@
- upload = g_new0(dls_device_upload_t, 1);
-
- upload->soup_session = soup_session_new();
- + upload->cancellable = g_cancellable_new();
- upload->msg = soup_message_new("POST", import_uri);
- upload->mapped_file = mapped_file;
- upload->body = body;
- @@ -4613,11 +4515,15 @@
- upload->status = DLS_UPLOAD_STATUS_IN_PROGRESS;
- upload->bytes_to_upload = up_body_length;
-
- - soup_message_headers_set_expectations(upload->msg->request_headers,
- + SoupMessageHeaders *headers =
- + soup_message_get_request_headers(upload->msg);
- + soup_message_headers_set_expectations(headers,
- SOUP_EXPECTATION_CONTINUE);
-
- - soup_message_set_request(upload->msg, mime_type, SOUP_MEMORY_STATIC,
- - up_body, up_body_length);
- + GInputStream *is = g_memory_input_stream_new_from_data(
- + up_body, up_body_length, NULL);
- + soup_message_set_request_body(upload->msg, mime_type, is,
- + up_body_length);
- g_signal_connect(upload->msg, "wrote-body-data",
- G_CALLBACK(prv_post_bytes_written), upload);
-
- @@ -4634,35 +4540,36 @@
- return NULL;
- }
-
- -static void prv_create_container_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_create_container_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- dls_async_task_t *cb_data = user_data;
- - const gchar *message;
- - GError *error = NULL;
- - gchar *result = NULL;
- - gchar *object_id = NULL;
- - gchar *object_path;
- - gboolean end;
- + g_autoptr(GError) error = NULL;
- + g_autofree gchar *result = NULL;
- + g_autofree gchar *object_id = NULL;
- + g_autofree gchar *object_path = NULL;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - &error, "ObjectID",
- - G_TYPE_STRING, &object_id,
- - "Result", G_TYPE_STRING, &result,
- - NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
-
- - if (!end || (object_id == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- - DLEYNA_LOG_WARNING("Create Object operation failed: %s",
- - message);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Create Object operation failed: %s",
- - message);
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error, "ObjectID", G_TYPE_STRING, &object_id,
- + "Result", G_TYPE_STRING, &result, NULL);
- + }
- +
- + if(error != NULL) {
- + DLEYNA_LOG_WARNING("Create Object operation failed: %s", error->message);
- +
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Create Object operation failed: %s", error->message);
- goto on_error;
- }
-
- @@ -4670,59 +4577,56 @@
- object_id);
- cb_data->task.result = g_variant_ref_sink(g_variant_new_object_path(
- object_path));
- - g_free(object_path);
- -
- on_error:
- -
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
- -
- - g_free(object_id);
- - g_free(result);
- -
- - if (error)
- - g_error_free(error);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- -static void prv_generic_upload_cb(dls_async_task_t *cb_data,
- - char *file_path,
- - gchar *body,
- - gsize body_length,
- - const gchar *mime_type)
- +static void prv_create_object_upload_cb(GObject *source, GAsyncResult *res,
- + gpointer user_data)
- {
- - gchar *object_id = NULL;
- - gchar *result = NULL;
- + dls_async_task_t *cb_data = user_data;
- + char *file_path = cb_data->task.ut.upload.file_path;
- + gchar *body = NULL;
- + gsize body_length = 0;
- + const gchar *mime_type = cb_data->ut.upload.mime_type;
- +
- gchar *import_uri = NULL;
- - gchar *object_path;
- - const gchar *message;
- - GError *error = NULL;
- gboolean delete_needed = FALSE;
- - gboolean end;
- gint *upload_id;
- - GUPnPDIDLLiteParser *parser = NULL;
- + g_autoptr(GUPnPDIDLLiteParser) parser = NULL;
- GVariant *out_p[2];
- dls_device_upload_t *upload;
- dls_device_upload_job_t *upload_job;
- + g_autoptr(GError) error = NULL;
- + g_autofree gchar *result = NULL;
- + g_autofree gchar *object_id = NULL;
- + g_autofree gchar *object_path = NULL;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - &error, "ObjectID",
- - G_TYPE_STRING, &object_id,
- - "Result", G_TYPE_STRING, &result,
- - NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - if (!end || (object_id == NULL) || (result == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error, "ObjectID", G_TYPE_STRING, &object_id,
- + "Result", G_TYPE_STRING, &result, NULL);
- + }
- +
- + if(error != NULL) {
- DLEYNA_LOG_WARNING("Create Object operation failed: %s",
- - message);
- + error->message);
- +
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Create Object operation failed: %s", error->message);
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Create Object operation failed: %s",
- - message);
- goto on_error;
- }
-
- @@ -4771,9 +4675,9 @@
- upload_job->device = cb_data->task.target.device;
- upload_job->upload_id = (gint) cb_data->task.target.device->upload_id;
-
- - soup_session_queue_message(upload->soup_session, upload->msg,
- - prv_post_finished, upload_job);
- - g_object_ref(upload->msg);
- + soup_session_send_and_read_async(
- + upload->soup_session, upload->msg, G_PRIORITY_DEFAULT,
- + upload->cancellable, prv_post_finished, upload_job);
-
- upload_id = g_new(gint, 1);
- *upload_id = upload_job->upload_id;
- @@ -4796,8 +4700,6 @@
- if (cb_data->task.target.device->upload_id > G_MAXINT)
- cb_data->task.target.device->upload_id = 0;
-
- - g_free(object_path);
- -
- on_error:
-
- if (cb_data->error && delete_needed) {
- @@ -4805,49 +4707,28 @@
- "Upload failed deleting created object with id %s",
- object_id);
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - cb_data->proxy, "DestroyObject",
- - prv_upload_delete_cb, cb_data,
- - "ObjectID", G_TYPE_STRING, object_id,
- - NULL);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "DestroyObject", "ObjectID", G_TYPE_STRING, object_id,
- + NULL);
- + gupnp_service_proxy_call_action_async(
- + cb_data->proxy, cb_data->action, cb_data->cancellable,
- + prv_upload_delete_cb, cb_data);
- +
- + // Fire and forget operation, we unref the action here.
- + gupnp_service_proxy_action_unref (cb_data->action);
- } else {
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable,
- - cb_data->cancel_id);
- }
-
- - g_free(object_id);
- - g_free(import_uri);
- -
- - if (parser)
- - g_object_unref(parser);
- -
- - g_free(result);
- -
- - if (error)
- - g_error_free(error);
- -
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- -static void prv_create_object_upload_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- -{
- - dls_async_task_t *cb_data = user_data;
- -
- - prv_generic_upload_cb(cb_data,
- - cb_data->task.ut.upload.file_path,
- - NULL, 0,
- - cb_data->ut.upload.mime_type);
- -}
- -
- void dls_device_upload(dls_client_t *client,
- dls_task_t *task, const gchar *parent_id)
- {
- dls_async_task_t *cb_data = (dls_async_task_t *)task;
- dls_device_context_t *context;
- - gchar *didl;
- + g_autofree gchar *didl;
- dls_async_upload_t *cb_task_data;
-
- DLEYNA_LOG_DEBUG("Enter");
- @@ -4869,19 +4750,13 @@
- g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - cb_data->proxy, "CreateObject",
- - prv_create_object_upload_cb, cb_data,
- - "ContainerID", G_TYPE_STRING, parent_id,
- - "Elements", G_TYPE_STRING, didl,
- - NULL);
- -
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- -
- - g_free(didl);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "CreateObject", "ContainerID", G_TYPE_STRING, parent_id,
- + "Elements", G_TYPE_STRING, didl, NULL);
- +
- + gupnp_service_proxy_call_action_async(
- + cb_data->proxy, cb_data->action, cb_data->cancellable,
- + prv_create_object_upload_cb, cb_data);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -4963,8 +4838,7 @@
- }
-
- if (upload->msg) {
- - soup_session_cancel_message(upload->soup_session, upload->msg,
- - SOUP_STATUS_CANCELLED);
- + g_cancellable_cancel(upload->cancellable);
- DLEYNA_LOG_DEBUG("Cancelling Upload %u ", upload_id);
- }
-
- @@ -4977,32 +4851,37 @@
- return retval;
- }
-
- -static void prv_destroy_object_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_destroy_object_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *upnp_error = NULL;
- + g_autoptr(GError) upnp_error = NULL;
- dls_async_task_t *cb_data = user_data;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - if (!gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - &upnp_error,
- - NULL)) {
- - DLEYNA_LOG_WARNING("Destroy Object operation failed: %s",
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &upnp_error);
- +
- + if(g_error_matches(upnp_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
- +
- + if(upnp_error == NULL) {
- + gupnp_service_proxy_action_get_result(action, &upnp_error,
- + NULL);
- + }
- +
- + if(upnp_error != NULL) {
- + DLEYNA_LOG_WARNING("Create Object operation failed: %s",
- upnp_error->message);
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Destroy Object operation failed: %s",
- - upnp_error->message);
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Create Object operation failed: %s",
- + upnp_error->message);
- }
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
- -
- - if (upnp_error)
- - g_error_free(upnp_error);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -5022,15 +4901,12 @@
- g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - cb_data->proxy, "DestroyObject",
- - prv_destroy_object_cb, cb_data,
- - "ObjectID", G_TYPE_STRING, task->target.id,
- - NULL);
- -
- - cb_data->cancel_id = g_cancellable_connect(cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "DestroyObject", "ObjectID", G_TYPE_STRING, task->target.id,
- + NULL);
- + gupnp_service_proxy_call_action_async(cb_data->proxy, cb_data->action,
- + cb_data->cancellable,
- + prv_destroy_object_cb, cb_data);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -5041,7 +4917,7 @@
- {
- dls_async_task_t *cb_data = (dls_async_task_t *)task;
- dls_device_context_t *context;
- - gchar *didl;
- + g_autofree gchar *didl = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- @@ -5064,19 +4940,13 @@
- g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - cb_data->proxy, "CreateObject",
- - prv_create_container_cb, cb_data,
- - "ContainerID", G_TYPE_STRING, parent_id,
- - "Elements", G_TYPE_STRING, didl,
- - NULL);
- -
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- -
- - g_free(didl);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "CreateObject", "ContainerID", G_TYPE_STRING, parent_id,
- + "Elements", G_TYPE_STRING, didl, NULL);
- +
- + gupnp_service_proxy_call_action_async(cb_data->proxy, cb_data->action,
- + cb_data->cancellable,
- + prv_create_container_cb, cb_data);
-
- on_error:
-
- @@ -5085,33 +4955,36 @@
- return;
- }
-
- -static void prv_update_object_update_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_update_object_update_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *upnp_error = NULL;
- + g_autoptr(GError) upnp_error = NULL;
- dls_async_task_t *cb_data = user_data;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - if (!gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - &upnp_error,
- - NULL)) {
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &upnp_error);
- + if(g_error_matches(upnp_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
- +
- + if(upnp_error == NULL) {
- + gupnp_service_proxy_action_get_result(action, &upnp_error,
- + NULL);
- + }
- +
- + if(upnp_error != NULL) {
- DLEYNA_LOG_WARNING("Update Object operation failed: %s",
- upnp_error->message);
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Update Object operation "
- - " failed: %s",
- - upnp_error->message);
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Update Object operation failed: %s",
- + upnp_error->message);
- }
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
- -
- - if (upnp_error)
- - g_error_free(upnp_error);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -5305,34 +5178,36 @@
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- -static void prv_update_object_browse_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_update_object_browse_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *error = NULL;
- + g_autoptr(GError) error = NULL;
- dls_async_task_t *cb_data = user_data;
- dls_async_update_t *cb_task_data = &cb_data->ut.update;
- - GUPnPDIDLLiteParser *parser = NULL;
- - gchar *result = NULL;
- - const gchar *message;
- - gboolean end;
- + g_autoptr(GUPnPDIDLLiteParser) parser = NULL;
- + g_autofree gchar *result = NULL;
- + g_autoptr(GUPnPServiceProxyAction) action = NULL;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - &error,
- - "Result", G_TYPE_STRING, &result,
- - NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - if (!end || (result == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- - DLEYNA_LOG_WARNING("Browse Object operation failed: %s",
- - message);
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error, "Result", G_TYPE_STRING, &result, NULL);
- + }
- +
- + if(error != NULL) {
- + DLEYNA_LOG_WARNING("Browse operation failed: %s",
- + error->message);
- +
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Browse operation failed: %s", error->message);
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Browse operation failed: %s",
- - message);
- goto on_error;
- }
-
- @@ -5367,32 +5242,24 @@
- goto on_error;
- }
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - cb_data->proxy, "UpdateObject",
- - prv_update_object_update_cb, cb_data,
- - "ObjectID", G_TYPE_STRING, cb_data->task.target.id,
- - "CurrentTagValue", G_TYPE_STRING,
- - cb_task_data->current_tag_value,
- - "NewTagValue", G_TYPE_STRING, cb_task_data->new_tag_value,
- - NULL);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "UpdateObject", "ObjectID", G_TYPE_STRING,
- + cb_data->task.target.id, "CurrentTagValue", G_TYPE_STRING,
- + cb_task_data->current_tag_value, "NewTagValue", G_TYPE_STRING,
- + cb_task_data->new_tag_value, NULL);
- +
- + gupnp_service_proxy_call_action_async(
- + cb_data->proxy, cb_data->action, cb_data->cancellable,
- + prv_update_object_update_cb, cb_data);
-
- goto no_complete;
-
- on_error:
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
-
- no_complete:
-
- - if (parser)
- - g_object_unref(parser);
- -
- - g_free(result);
- -
- - if (error)
- - g_error_free(error);
- -
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- @@ -5412,50 +5279,48 @@
- g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - cb_data->proxy, "Browse",
- - prv_update_object_browse_cb, cb_data,
- - "ObjectID", G_TYPE_STRING, task->target.id,
- - "BrowseFlag", G_TYPE_STRING, "BrowseMetadata",
- - "Filter", G_TYPE_STRING, upnp_filter,
- - "StartingIndex", G_TYPE_INT, 0,
- - "RequestedCount", G_TYPE_INT, 0,
- - "SortCriteria", G_TYPE_STRING,
- - "", NULL);
-
- - cb_data->cancel_id = g_cancellable_connect(cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "Browse", "ObjectID", G_TYPE_STRING, task->target.id,
- + "BrowseFlag", G_TYPE_STRING, "BrowseMetadata", "Filter",
- + G_TYPE_STRING, upnp_filter, "StartingIndex", G_TYPE_INT, 0,
- + "RequestedCount", G_TYPE_INT, 0, "SortCriteria", G_TYPE_STRING,
- + "", NULL);
- +
- + gupnp_service_proxy_call_action_async(
- + cb_data->proxy, cb_data->action, cb_data->cancellable,
- + prv_update_object_browse_cb, cb_data);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- -static void prv_get_object_metadata_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_get_object_metadata_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *error = NULL;
- + g_autoptr(GError) error = NULL;
- dls_async_task_t *cb_data = user_data;
- - gchar *result = NULL;
- - const gchar *message;
- - gboolean end;
- + g_autofree gchar *result = NULL;
- + g_autoptr(GUPnPServiceProxyAction) action;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - &error,
- - "Result", G_TYPE_STRING, &result,
- - NULL);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - if (!end || (result == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- - DLEYNA_LOG_WARNING("Browse Object operation failed: %s",
- - message);
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(
- + action, &error, "Result", G_TYPE_STRING, &result, NULL);
- + }
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Browse operation failed: %s",
- - message);
- + if(error != NULL) {
- + DLEYNA_LOG_WARNING("Browse operation failed: %s",
- + error->message);
- +
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "Browse operation failed: %s", error->message);
- goto on_complete;
- }
-
- @@ -5463,15 +5328,9 @@
-
- DLEYNA_LOG_DEBUG("prv_get_object_metadata_cb result: %s", result);
-
- - g_free(result);
- -
- on_complete:
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
- -
- - if (error)
- - g_error_free(error);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -5492,52 +5351,50 @@
- g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - cb_data->proxy, "Browse",
- - prv_get_object_metadata_cb, cb_data,
- - "ObjectID", G_TYPE_STRING, task->target.id,
- - "BrowseFlag", G_TYPE_STRING, "BrowseMetadata",
- - "Filter", G_TYPE_STRING, "*",
- - "StartingIndex", G_TYPE_INT, 0,
- - "RequestedCount", G_TYPE_INT, 0,
- - "SortCriteria", G_TYPE_STRING, "",
- - NULL);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "Browse", "ObjectID", G_TYPE_STRING, task->target.id,
- + "BrowseFlag", G_TYPE_STRING, "BrowseMetadata", "Filter",
- + G_TYPE_STRING, "*", "StartingIndex", G_TYPE_INT, 0,
- + "RequestedCount", G_TYPE_INT, 0, "SortCriteria", G_TYPE_STRING,
- + "", NULL);
- +
- + gupnp_service_proxy_call_action_async(
- + cb_data->proxy, cb_data->action, cb_data->cancellable,
- + prv_get_object_metadata_cb, cb_data);
-
- - cb_data->cancel_id = g_cancellable_connect(cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- -static void prv_create_reference_cb(GUPnPServiceProxy *proxy,
- - GUPnPServiceProxyAction *action,
- - gpointer user_data)
- +static void prv_create_reference_cb(GObject *source, GAsyncResult *res, gpointer user_data)
- {
- - GError *error = NULL;
- + g_autoptr(GError) error = NULL;
- dls_async_task_t *cb_data = user_data;
- - const gchar *message;
- - gchar *object_id = NULL;
- - gchar *object_path;
- - gboolean end;
- + g_autofree gchar *object_id = NULL;
- + g_autofree gchar *object_path = NULL;
- + g_autoptr(GUPnPServiceProxyAction) action;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - end = gupnp_service_proxy_end_action(cb_data->proxy, cb_data->action,
- - &error,
- - "NewID", G_TYPE_STRING, &object_id,
- - NULL);
- - if (!end || (object_id == NULL)) {
- - message = (error != NULL) ? error->message : "Invalid result";
- - DLEYNA_LOG_WARNING("CreateReference operation failed: %s",
- - message);
- + action = gupnp_service_proxy_call_action_finish(cb_data->proxy, res,
- + &error);
- + if(g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- + return;
- + }
-
- - cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- - DLEYNA_ERROR_OPERATION_FAILED,
- - "Update Object operation "
- - " failed: %s",
- - message);
- + if(error == NULL) {
- + gupnp_service_proxy_action_get_result(action, &error, "NewID",
- + G_TYPE_STRING, &object_id,
- + NULL);
- + }
- +
- + if(error != NULL) {
- + DLEYNA_LOG_WARNING("CreateReference operation failed: %s",
- + error->message);
-
- + cb_data->error = g_error_new(
- + DLEYNA_SERVER_ERROR, DLEYNA_ERROR_OPERATION_FAILED,
- + "CreateReference operation failed: %s", error->message);
- goto on_error;
- }
-
- @@ -5548,17 +5405,9 @@
-
- cb_data->task.result = g_variant_ref_sink(g_variant_new_object_path(
- object_path));
- - g_free(object_path);
- -
- on_error:
-
- (void) g_idle_add(dls_async_task_complete, cb_data);
- - g_cancellable_disconnect(cb_data->cancellable, cb_data->cancel_id);
- -
- - g_free(object_id);
- -
- - if (error != NULL)
- - g_error_free(error);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -5568,8 +5417,8 @@
- {
- dls_async_task_t *cb_data = (dls_async_task_t *)task;
- dls_device_context_t *context;
- - gchar *i_root = NULL;
- - gchar *i_id = NULL;
- + g_autofree gchar *i_root = NULL;
- + g_autofree gchar *i_id = NULL;
- gchar *path = cb_data->task.ut.create_reference.item_path;
-
- DLEYNA_LOG_DEBUG("Enter");
- @@ -5594,23 +5443,15 @@
- g_object_add_weak_pointer((G_OBJECT(context->cds.proxy)),
- (gpointer *)&cb_data->proxy);
-
- - cb_data->action = gupnp_service_proxy_begin_action(
- - cb_data->proxy, "CreateReference",
- - prv_create_reference_cb, cb_data,
- - "ContainerID", G_TYPE_STRING, task->target.id,
- - "ObjectID", G_TYPE_STRING, i_id,
- - NULL);
- -
- - cb_data->cancel_id = g_cancellable_connect(
- - cb_data->cancellable,
- - G_CALLBACK(dls_async_task_cancelled_cb),
- - cb_data, NULL);
- + cb_data->action = gupnp_service_proxy_action_new(
- + "CreateReference", "ContainerID", G_TYPE_STRING,
- + task->target.id, "ObjectID", G_TYPE_STRING, i_id, NULL);
- +
- + gupnp_service_proxy_call_action_async(cb_data->proxy, cb_data->action,
- + cb_data->cancellable,
- + prv_create_reference_cb, cb_data);
-
- on_error:
- -
- - g_free(i_root);
- - g_free(i_id);
- -
- DLEYNA_LOG_DEBUG("Exit");
- }
-
- @@ -5618,9 +5459,11 @@
- {
- GVariant *out_p[2];
-
- + gsize size;
- + gconstpointer data = g_bytes_get_data(device->icon.bytes, &size);
- out_p[0] = g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE,
- - device->icon.bytes,
- - device->icon.size,
- + data,
- + size,
- 1);
- out_p[1] = g_variant_new_string(device->icon.mime_type);
- task->result = g_variant_ref_sink(g_variant_new_tuple(out_p, 2));
- @@ -5634,8 +5477,7 @@
- dls_async_task_cancelled_cb(cancellable, download->task);
-
- if (download->msg) {
- - soup_session_cancel_message(download->session, download->msg,
- - SOUP_STATUS_CANCELLED);
- + g_cancellable_cancel(download->cancellable);
- DLEYNA_LOG_DEBUG("Cancelling device icon download");
- }
- }
- @@ -5644,31 +5486,39 @@
- {
- if (download->msg)
- g_object_unref(download->msg);
- + if(download->cancellable)
- + g_object_unref(download->cancellable);
- g_object_unref(download->session);
- g_free(download);
- }
-
- -static void prv_get_icon_session_cb(SoupSession *session,
- - SoupMessage *msg,
- +static void prv_get_icon_session_cb(GObject *source,
- + GAsyncResult *res,
- gpointer user_data)
- {
- dls_device_download_t *download = (dls_device_download_t *)user_data;
- dls_async_task_t *cb_data = (dls_async_task_t *)download->task;
- dls_device_t *device = (dls_device_t *)cb_data->task.target.device;
- + g_autoptr(GError) error = NULL;
- + GBytes *data;
- +
- + data = soup_session_send_and_read_finish(SOUP_SESSION(source), res,
- + &error);
-
- - if (msg->status_code == SOUP_STATUS_CANCELLED)
- + if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- goto out;
-
- - if (SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) {
- - device->icon.size = msg->response_body->length;
- - device->icon.bytes = g_malloc(device->icon.size);
- - memcpy(device->icon.bytes, msg->response_body->data,
- - device->icon.size);
- + SoupStatus status = soup_message_get_status(download->msg);
- +
- + if (SOUP_STATUS_IS_SUCCESSFUL(status)) {
- + device->icon.bytes = data;
-
- prv_build_icon_result(device, &cb_data->task);
- } else {
- DLEYNA_LOG_DEBUG("Failed to GET device icon: %s",
- - msg->reason_phrase);
- + error != NULL
- + ? error->message
- + : soup_message_get_reason_phrase(download->msg));
-
- cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- DLEYNA_ERROR_OPERATION_FAILED,
- @@ -5689,10 +5539,10 @@
- dls_device_context_t *context;
- dls_async_task_t *cb_data = (dls_async_task_t *)task;
- dls_device_t *device = task->target.device;
- - gchar *url;
- + g_autofree gchar *url;
- dls_device_download_t *download;
-
- - if (device->icon.size != 0) {
- + if (device->icon.bytes != NULL) {
- prv_build_icon_result(device, task);
- goto end;
- }
- @@ -5714,6 +5564,7 @@
- download->session = soup_session_new();
- download->msg = soup_message_new(SOUP_METHOD_GET, url);
- download->task = cb_data;
- + download->cancellable = g_cancellable_new();
-
- if (!download->msg) {
- DLEYNA_LOG_WARNING("Invalid URL %s", url);
- @@ -5732,11 +5583,9 @@
- G_CALLBACK(prv_get_icon_cancelled),
- download, NULL);
-
- - g_object_ref(download->msg);
- - soup_session_queue_message(download->session, download->msg,
- - prv_get_icon_session_cb, download);
- -
- - g_free(url);
- + soup_session_send_and_read_async(
- + download->session, download->msg, G_PRIORITY_DEFAULT,
- + download->cancellable, prv_get_icon_session_cb, download);
-
- return;
-
- diff -Nuar a/libdleyna/server/device.h b/libdleyna/server/device.h
- --- a/libdleyna/server/device.h 2021-10-26 18:17:55.000000000 +0300
- +++ b/libdleyna/server/device.h 2022-06-02 23:36:05.000000000 +0300
- @@ -64,8 +64,7 @@
- typedef struct dls_device_icon_t_ dls_device_icon_t;
- struct dls_device_icon_t_ {
- gchar *mime_type;
- - guchar *bytes;
- - gsize size;
- + GBytes *bytes;
- };
-
- struct dls_device_t_ {
- diff -Nuar a/libdleyna/server/manager.c b/libdleyna/server/manager.c
- --- a/libdleyna/server/manager.c 2021-10-26 18:17:55.000000000 +0300
- +++ b/libdleyna/server/manager.c 2022-06-02 23:36:05.000000000 +0300
- @@ -20,13 +20,14 @@
- *
- */
-
- +#include <config.h>
- +
- #include <glib.h>
- #include <string.h>
-
- #include <libdleyna/core/error.h>
- #include <libdleyna/core/log.h>
- -#include <libdleyna/core/service-task.h>
- -#include <libdleyna/core/white-list.h>
- +#include <libdleyna/core/context-filter.h>
-
- #include "interface.h"
- #include "manager.h"
- @@ -35,10 +36,10 @@
- struct dls_manager_t_ {
- dleyna_connector_id_t connection;
- GUPnPContextManager *cm;
- - dleyna_white_list_t *wl;
- + dleyna_context_filter_t *cf;
- };
-
- -static void prv_wl_notify_prop(dls_manager_t *manager,
- +static void prv_cf_notify_prop(dls_manager_t *manager,
- const gchar *prop_name,
- GVariant *prop_val)
- {
- @@ -64,13 +65,13 @@
- GUPnPContextManager *connection_manager)
- {
- dls_manager_t *manager = g_new0(dls_manager_t, 1);
- - GUPnPWhiteList *gupnp_wl;
- + GUPnPContextFilter *gupnp_cf;
-
- - gupnp_wl = gupnp_context_manager_get_white_list(connection_manager);
- + gupnp_cf = gupnp_context_manager_get_context_filter(connection_manager);
-
- manager->connection = connection;
- manager->cm = connection_manager;
- - manager->wl = dleyna_white_list_new(gupnp_wl);
- + manager->cf = dleyna_context_filter_new(gupnp_cf);
-
- return manager;
- }
- @@ -78,14 +79,14 @@
- void dls_manager_delete(dls_manager_t *manager)
- {
- if (manager != NULL) {
- - dleyna_white_list_delete(manager->wl);
- + dleyna_context_filter_delete(manager->cf);
- g_free(manager);
- }
- }
-
- -dleyna_white_list_t *dls_manager_get_white_list(dls_manager_t *manager)
- +dleyna_context_filter_t *dls_manager_get_context_filter(dls_manager_t *manager)
- {
- - return manager->wl;
- + return manager->cf;
- }
-
- void dls_manager_get_all_props(dls_manager_t *manager,
- @@ -188,7 +189,7 @@
-
- if (*error == NULL) {
- prop_val = g_variant_new_boolean(never_quit);
- - prv_wl_notify_prop(manager,
- + prv_cf_notify_prop(manager,
- DLS_INTERFACE_PROP_NEVER_QUIT,
- prop_val);
- }
- @@ -198,7 +199,7 @@
- return;
- }
-
- -static void prv_set_prop_wl_enabled(dls_manager_t *manager,
- +static void prv_set_prop_cf_enabled(dls_manager_t *manager,
- dleyna_settings_t *settings,
- gboolean enabled,
- GError **error)
- @@ -208,20 +209,20 @@
-
- DLEYNA_LOG_DEBUG("Enter %d", enabled);
-
- - old_val = dleyna_settings_is_white_list_enabled(settings);
- + old_val = dleyna_settings_is_context_filter_enabled(settings);
-
- if (old_val == enabled)
- goto exit;
-
- /* If no error, the white list will be updated in the reload callack
- */
- - dleyna_settings_set_white_list_enabled(settings, enabled, error);
- + dleyna_settings_set_context_filter_enabled(settings, enabled, error);
-
- if (*error == NULL) {
- - dleyna_white_list_enable(manager->wl, enabled);
- + dleyna_context_filter_enable(manager->cf, enabled);
-
- prop_val = g_variant_new_boolean(enabled);
- - prv_wl_notify_prop(manager,
- + prv_cf_notify_prop(manager,
- DLS_INTERFACE_PROP_WHITE_LIST_ENABLED,
- prop_val);
- }
- @@ -231,7 +232,7 @@
- return;
- }
-
- -static void prv_set_prop_wl_entries(dls_manager_t *manager,
- +static void prv_set_prop_cf_entries(dls_manager_t *manager,
- dleyna_settings_t *settings,
- GVariant *entries,
- GError **error)
- @@ -250,13 +251,13 @@
- /* If no error, the white list will be updated in the reload callack
- * callack
- */
- - dleyna_settings_set_white_list_entries(settings, entries, error);
- + dleyna_settings_set_context_filter_entries(settings, entries, error);
-
- if (*error == NULL) {
- - dleyna_white_list_clear(manager->wl);
- - dleyna_white_list_add_entries(manager->wl, entries);
- + dleyna_context_filter_clear(manager->cf);
- + dleyna_context_filter_add_entries(manager->cf, entries);
-
- - prv_wl_notify_prop(manager,
- + prv_cf_notify_prop(manager,
- DLS_INTERFACE_PROP_WHITE_LIST_ENTRIES,
- entries);
- }
- @@ -299,11 +300,11 @@
- g_variant_get_boolean(param),
- &error);
- else if (!strcmp(name, DLS_INTERFACE_PROP_WHITE_LIST_ENABLED))
- - prv_set_prop_wl_enabled(manager, settings,
- + prv_set_prop_cf_enabled(manager, settings,
- g_variant_get_boolean(param),
- &error);
- else if (!strcmp(name, DLS_INTERFACE_PROP_WHITE_LIST_ENTRIES))
- - prv_set_prop_wl_entries(manager, settings, param, &error);
- + prv_set_prop_cf_entries(manager, settings, param, &error);
- else
- cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
- DLEYNA_ERROR_UNKNOWN_PROPERTY,
- diff -Nuar a/libdleyna/server/manager.h b/libdleyna/server/manager.h
- --- a/libdleyna/server/manager.h 2021-10-26 18:17:55.000000000 +0300
- +++ b/libdleyna/server/manager.h 2022-06-02 23:36:05.000000000 +0300
- @@ -26,6 +26,7 @@
- #include <libdleyna/core/connector.h>
- #include <libdleyna/core/settings.h>
- #include <libgupnp/gupnp-context-manager.h>
- +#include <libdleyna/core/context-filter.h>
-
- #include "task.h"
-
- @@ -37,7 +38,7 @@
-
- void dls_manager_delete(dls_manager_t *manager);
-
- -dleyna_white_list_t *dls_manager_get_white_list(dls_manager_t *manager);
- +dleyna_context_filter_t *dls_manager_get_context_filter(dls_manager_t *manager);
-
- void dls_manager_get_all_props(dls_manager_t *manager,
- dleyna_settings_t *settings,
- diff -Nuar a/libdleyna/server/meson.build b/libdleyna/server/meson.build
- --- a/libdleyna/server/meson.build 2021-10-26 18:17:55.000000000 +0300
- +++ b/libdleyna/server/meson.build 2022-06-02 23:36:05.000000000 +0300
- @@ -62,7 +62,7 @@
- name: 'dleyna-server-service-1.0',
- description: 'UPnP & DLNA server library',
- version: meson.project_version(),
- - requires: ['gupnp-1.2', 'glib-2.0', 'gio-2.0', 'dleyna-core-1.0'],
- + requires: ['gupnp-1.6', 'glib-2.0', 'gio-2.0', 'dleyna-core-1.0'],
- install_dir: join_paths(get_option('prefix'), get_option('libdir'), 'pkgconfig')
- )
-
- diff -Nuar a/libdleyna/server/props.c b/libdleyna/server/props.c
- --- a/libdleyna/server/props.c 2021-10-26 18:17:55.000000000 +0300
- +++ b/libdleyna/server/props.c 2022-06-02 23:36:05.000000000 +0300
- @@ -2105,7 +2105,7 @@
- {
- GVariant *result;
-
- - result = dleyna_settings_white_list_entries(settings);
- + result = dleyna_settings_context_filter_entries(settings);
-
- if (result == NULL)
- result = g_variant_new("as", NULL);
- @@ -2119,7 +2119,7 @@
- dleyna_settings_is_never_quit(settings));
-
- prv_add_bool_prop(vb, DLS_INTERFACE_PROP_WHITE_LIST_ENABLED,
- - dleyna_settings_is_white_list_enabled(settings));
- + dleyna_settings_is_context_filter_enabled(settings));
-
- g_variant_builder_add(vb, "{sv}", DLS_INTERFACE_PROP_WHITE_LIST_ENTRIES,
- prv_build_wl_entries(settings));
- @@ -2138,7 +2138,7 @@
- b_value = dleyna_settings_is_never_quit(settings);
- retval = g_variant_ref_sink(g_variant_new_boolean(b_value));
- } else if (!strcmp(prop, DLS_INTERFACE_PROP_WHITE_LIST_ENABLED)) {
- - b_value = dleyna_settings_is_white_list_enabled(settings);
- + b_value = dleyna_settings_is_context_filter_enabled(settings);
- retval = g_variant_ref_sink(g_variant_new_boolean(b_value));
- } else if (!strcmp(prop, DLS_INTERFACE_PROP_WHITE_LIST_ENTRIES)) {
- retval = g_variant_ref_sink(prv_build_wl_entries(settings));
- diff -Nuar a/libdleyna/server/server.c b/libdleyna/server/server.c
- --- a/libdleyna/server/server.c 2021-10-26 18:17:55.000000000 +0300
- +++ b/libdleyna/server/server.c 2022-06-02 23:36:05.000000000 +0300
- @@ -21,15 +21,17 @@
- *
- */
-
- +#include <config.h>
- +
- #include <glib.h>
- #include <string.h>
-
- #include <libdleyna/core/connector.h>
- +#include <libdleyna/core/context-filter.h>
- #include <libdleyna/core/control-point.h>
- #include <libdleyna/core/error.h>
- #include <libdleyna/core/log.h>
- #include <libdleyna/core/task-processor.h>
- -#include <libdleyna/core/white-list.h>
-
- #include "async.h"
- #include "client.h"
- @@ -1293,21 +1295,21 @@
- return g_context.upnp;
- }
-
- -static void prv_white_list_init(void)
- +static void prv_context_filter_init(void)
- {
- gboolean enabled;
- GVariant *entries;
- - dleyna_white_list_t *wl;
- + dleyna_context_filter_t *wl;
-
- DLEYNA_LOG_DEBUG("Enter");
-
- - enabled = dleyna_settings_is_white_list_enabled(g_context.settings);
- - entries = dleyna_settings_white_list_entries(g_context.settings);
- + enabled = dleyna_settings_is_context_filter_enabled(g_context.settings);
- + entries = dleyna_settings_context_filter_entries(g_context.settings);
-
- - wl = dls_manager_get_white_list(g_context.manager);
- + wl = dls_manager_get_context_filter(g_context.manager);
-
- - dleyna_white_list_enable(wl, enabled);
- - dleyna_white_list_add_entries(wl, entries);
- + dleyna_context_filter_enable(wl, enabled);
- + dleyna_context_filter_add_entries(wl, entries);
-
- DLEYNA_LOG_DEBUG("Exit");
- }
- @@ -1340,7 +1342,7 @@
- dls_upnp_get_context_manager(
- g_context.upnp));
-
- - prv_white_list_init();
- + prv_context_filter_init();
- } else {
- retval = FALSE;
- }
- diff -Nuar a/libdleyna/server/upnp.c b/libdleyna/server/upnp.c
- --- a/libdleyna/server/upnp.c 2021-10-26 18:17:55.000000000 +0300
- +++ b/libdleyna/server/upnp.c 2022-06-02 23:36:05.000000000 +0300
- @@ -20,6 +20,8 @@
- *
- */
-
- +#include <config.h>
- +
- #include <string.h>
-
- #include <libgssdp/gssdp-resource-browser.h>
- @@ -28,7 +30,7 @@
-
- #include <libdleyna/core/error.h>
- #include <libdleyna/core/log.h>
- -#include <libdleyna/core/service-task.h>
- +#include <libdleyna/core/gasync-task.h>
-
- #include "async.h"
- #include "device.h"
- @@ -123,12 +125,12 @@
-
- queue_id = dleyna_task_processor_add_queue(
- dls_server_get_task_processor(),
- - dleyna_service_task_create_source(),
- + dleyna_gasync_task_create_source(),
- DLS_SERVER_SINK,
- DLEYNA_TASK_QUEUE_FLAG_AUTO_REMOVE,
- - dleyna_service_task_process_cb,
- - dleyna_service_task_cancel_cb,
- - dleyna_service_task_delete_cb);
- + dleyna_gasync_task_process_cb,
- + dleyna_gasync_task_cancel_cb,
- + dleyna_gasync_task_delete_cb);
- dleyna_task_queue_set_finally(queue_id, prv_device_chain_end);
- dleyna_task_queue_set_user_data(queue_id, *priv_t);
-
- @@ -212,7 +214,7 @@
- udn = gupnp_device_info_get_udn(device_proxy);
-
- ip_address = gssdp_client_get_host_ip(
- - GSSDP_CLIENT(gupnp_control_point_get_context(cp)));
- + gssdp_resource_browser_get_client(GSSDP_RESOURCE_BROWSER(cp)));
-
- if (!udn || !ip_address)
- goto on_error;
- @@ -352,7 +354,7 @@
- udn = gupnp_device_info_get_udn((GUPnPDeviceInfo *)proxy);
-
- ip_address = gssdp_client_get_host_ip(
- - GSSDP_CLIENT(gupnp_control_point_get_context(cp)));
- + gssdp_resource_browser_get_client(GSSDP_RESOURCE_BROWSER(cp)));
-
- if (!udn || !ip_address)
- goto on_error;
- diff -Nuar a/meson.build b/meson.build
- --- a/meson.build 2021-10-26 18:17:55.000000000 +0300
- +++ b/meson.build 2022-06-02 23:36:05.000000000 +0300
- @@ -1,4 +1,4 @@
- -project('dleyna-server', 'c', version: '0.7.2')
- +project('dleyna-server', 'c', version: '0.8.0')
-
- pkg = import('pkgconfig')
-
- @@ -67,12 +67,12 @@
-
- glib = dependency('glib-2.0', version: '>= 2.28')
- gio = dependency('gio-2.0', version: '>=2.28')
- -gssdp = dependency('gssdp-1.2', version: '>= 1.2.0')
- -gupnp = dependency('gupnp-1.2', version: '>= 1.2.0')
- +gssdp = dependency('gssdp-1.6', version: '>= 1.2.0')
- +gupnp = dependency('gupnp-1.6', version: '>= 1.2.0')
- gupnp_av = dependency('gupnp-av-1.0', version: '>= 0.12.9')
- gupnp_dlna = dependency('gupnp-dlna-2.0', version: '>= 0.9.4')
- -soup = dependency('libsoup-2.4', version: '>= 2.28.2')
- -dleyna_core = dependency('dleyna-core-1.0', version: '>= 0.6.0', fallback: 'dleyna-core-1.0')
- +soup = dependency('libsoup-3.0', version: '>= 3.0')
- +dleyna_core = dependency('dleyna-core-1.0', version: '>= 0.8.0', fallback: 'dleyna-core-1.0')
- libxml2 = dependency('libxml-2.0')
-
- cc = meson.get_compiler('c')
|