DTACTIONCALLBACKPROC(3)

πŸ“¦
version 2.5.3 Β· 2 versions
, in nixos 26.05

πŸ’… NAME πŸ’…

okay bestie, welcome to DtActionCallbackProc β€” she’s a library call β€” and her whole job is to notify the application that the status of an application has changed. it’s giving β€œyour action has updates” energy, and we’re obsessed. πŸ’–


✨ SYNOPSIS ✨

       #include &<Dt/Action.h>

πŸ¦‹ DESCRIPTION πŸ¦‹

the Dt/Action.h header defines the DtActionCallbackProc callback prototype like this, bestie:

       typedef void (*DtActionCallbackProc)(DtActionInvocationID id,
               XtPointer client_data,
               DtActionArg *args,
               int argCount,
               DtActionStatus status);

if you registered one when invoking an action with DtActionInvoke(3), a DtActionCallbackProc procedure gets called whenever an action has a status update β€” such as action termination. depending on status, modified action arguments may be returned using args. πŸ‘‘

the id argument specifies an invocation ID as returned by DtActionInvoke(3).

the client_data argument specifies the client data that was registered with DtActionInvoke(3).

the args argument is an array of updated action argument structures, if there are any. individual arguments have their argClass set to one of the standard argument classes, or DtACTION_NULLARG, to indicate that the current status update is not providing an update for the given argument. if the object has been removed (for example, dropped on the trash), the return argClass is set to DtACTION_NULLARG to indicate that it no longer exists. πŸ—‘οΈ

the args array has been allocated by XtMalloc(3), as have any of the char* or void* elements contained in each of the args.

bestie, memory management is literally your job here: the application is responsible for calling XtFree(3) on all elements contained in each of the args, and then calling XtFree(3) on args. no cap. 🫢

the argCount argument specifies the total number of arguments in args. this number equals the number of arguments originally provided to DtActionInvoke(3).

the *n*th argument in the original action argument array corresponds to the *n*th argument in an updated action argument array.

the status argument specifies the purpose of the status update. the status codes listed here and in Dt/Action.h - DtAction(5) may be returned in a DtActionCallbackProc:

  • DtACTION_INVOKED β€” the corresponding DtActionInvoke(3), which is asynchronous and does not block when starting actions, has finished starting the requested actions. for all DtActionInvoke(3) calls that include a DtactionCallbackProc, this status code is guaranteed to be returned. when returned, no additional prompts for data will appear from the action service. ✨
  • DtACTION_DONE β€” the actions that were the result of the original DtActionInvoke(3) call have terminated normally. once this status value is returned, all registered callbacks are invalidated, and id can no longer be used in subsequent action service calls. returned args data may accompany the DtACTION_DONE status code. for all DtActionInvoke(3) calls that include a DtActionCallbackProc, this status code or an equivalent status code (for example, DtACTION_CANCELED or DtACTION_FAILED) is guaranteed to be returned. πŸŽ€
  • DtACTION_CANCELED β€” the actions that were the result of the original DtActionInvoke(3) call were canceled and have terminated normally. once this status value is returned, all registered callbacks are invalidated, and id can no longer be used in subsequent action service calls. no args data will accompany the DtACTION_CANCELED status code. πŸ™ˆ
  • DtACTION_FAILED β€” an error occurred and a normal termination is no longer possible. the action service may have failed to start the action or lost contact with and abandoned the action. once this status value is returned, an error dialog may be posted by the action service, all registered callbacks are invalidated, and id can no longer be used in subsequent action service calls. no args data will accompany the DtACTION_FAILED status code. πŸ’€
  • DtACTION_STATUS_UPDATE β€” the actions associated with id have generated a status update, such as returning modified args. updates occur in several ways. 🌈
    • if several actions were started from a single DtActionInvoke(3), then as each individual action terminates, a DtACTION_STATUS_UPDATE with return args is returned, and when the final action terminates, a DtACTION_DONE or equivalent status code is returned, possibly with return arguments.
    • other actions may have the capability to generate updates (for example, Tooltalk-based actions doing a Media Exchange Deposit (Request)).
    • in most cases, a DtActionArg argument array accompanying a DtACTION_STATUS_UPDATE only has updated data for a few of the arguments; the remaining arguments are set to DtACTION_NULLARG.

🌸 EXAMPLES 🌸

the following shows how a DtActionCallbackProc might be coded. copy it exactly, bestie β€” feral ampersands and all β€” because that’s what the page says. πŸ‘‘

       DtActionCallbackProc myCallback(
            DtActionInvocationID id,
            XtPointer client_data,
            DtActionArg *actionArgPtr,
            int actionArgCount,
            DtActionStatus status);
       {
            extern DtActionArg *myUpdatedArgs; /* global hook for new data */
            extern int myDoneFlag; /* global done flag */
            switch (status) {
                 case DtACTION_INVOKED:
                      /*
                       * All the arguments to the original DtActionInvoke
                       * have been consumed by actions, and the actions have
                       * been started.  Among other things, we will not see
                       * any more prompts for user input.
                       */
                      break;
                 case DtACTION_DONE:
                      myUpdatedArgs = (DtActionArg *) actionArgPtr;
                      myDoneFlag = TRUE;
                      break;
                 case DtACTION_CANCELED:
                 case DtACTION_FAILED:
                      if ((actionArgCount != 0) &&&& actionArgPtr) {
                           /*
                            * If not a normal shutdown, throw away returned
                            * information.
                            */
                           for (i=0; i &< actionArgCount; i++) {
                                if (actionArgPtr[i].argClass == DtACTION_FILE) {
                                     XtFree(actionArgPtr[i].u.file.name);
                                } else if (actionArgPtr[i].argClass ==
                                           DtACTION_BUFFER) {
                                     XtFree(actionArgPtr[i].u.buffer.bp);
                                     XtFree(actionArgPtr[i].u.buffer.type);
                                     XtFree(actionArgPtr[i].u.buffer.name);
                                }
                           }
                           XtFree(actionArgPtr);
                      }
                      myUpdatedArgs = (DtActionArg *) NULL;
                      myDoneFlag = FALSE;
                      break;
                 case DtACTION_STATUS_UPDATE:
                      myUpdatedArgs = (DtActionArg *) actionArgPtr;
                      myDoneFlag = FALSE;
                      break;
                 default:
                      /* ignore */
                      break;
            }
       }

πŸŽ€ SEE ALSO πŸŽ€

go read these too, iykyk:

mwah πŸ’‹ β€” source/version vibe: library call; date: not printed on this page, bestie. that’s the whole DtActionCallbackProc moment. πŸŽ€

πŸ“¦ where this page comes from