Calling base class methods

Sven Schwermer sven at svenschwermer.de
Wed Mar 9 12:45:14 UTC 2022


Hi,

I have a question around how to properly call base class methods and 
passing the async result back to the caller. Consider the following 
scenario:

* MMBroadbandBearerFibocomEcm inherits from MMBroadbandBearer
* MMBroadbandBearerFibocomEcm implements its own connect_3gpp and 
connect_3gpp_finish
* In certain cases MMBroadbandBearerFibocomEcm::connect_3gpp wants to 
call MMBroadbandBearer::connect_3gpp

Here's what I got for MMBroadbandBearerFibocomEcm:

static void
parent_connect_ready (MMBroadbandBearer *bearer,
                       GAsyncResult      *res,
                       GTask             *task)
{
     /* TODO how to propagate the result back to the original callback? */
}

static void
connect_3gpp (MMBroadbandBearer *self,
               MMBroadbandModem *modem,
               MMPortSerialAt *primary,
               MMPortSerialAt *secondary,
               GCancellable *cancellable,
               GAsyncReadyCallback callback,
               gpointer user_data)
{
     GTask *task = g_task_new (self, cancellable, callback, user_data);
     if (some_condition) {
         MM_BROADBAND_BEARER_CLASS 
(mm_broadband_bearer_fibocom_ecm_parent_class)->connect_3gpp (
             MM_BROADBAND_BEARER (self),
             modem,
             primary,
             secondary,
             cancellable,
             (GAsyncReadyCallback) parent_connect_ready,
             task
         );
     } else {
         /* some other code path */
     }
}

Is there a way to directly invoke the original callback from the 
parent_connect_ready callback with the result res? How would I do this 
best? I don't want to re-implement everything from 
MMBroadbandBearer::connect_3gpp_ready because that does a bunch with 
connect_succeeded which is private.

Best regards,
Sven


More information about the ModemManager-devel mailing list