gdm_session_worker_process_extended_pam_message (GdmSessionWorker          *worker,
                                                 const struct pam_message  *query,
                                                 char                     **response)
{
        GdmPamExtensionMessage *extended_message;
        gboolean res;

        extended_message = GDM_PAM_EXTENSION_MESSAGE_FROM_PAM_MESSAGE (query);

        if (GDM_PAM_EXTENSION_MESSAGE_TRUNCATED (extended_message)) {
                g_warning ("PAM service requested binary response for truncated query");
                return FALSE;
        }

        if (GDM_PAM_EXTENSION_MESSAGE_INVALID_TYPE (extended_message)) {
                g_warning ("PAM service requested binary response for unadvertised query type");
                return FALSE;
        }

        if (GDM_PAM_EXTENSION_MESSAGE_MATCH (extended_message, worker->priv->extensions, GDM_PAM_EXTENSION_CHOICE_LIST)) {
                GdmPamExtensionChoiceListRequest *list_request = (GdmPamExtensionChoiceListRequest *) extended_message;
                GdmPamExtensionChoiceListResponse *list_response = malloc (GDM_PAM_EXTENSION_CHOICE_LIST_RESPONSE_SIZE);

                g_debug ("GdmSessionWorker: received extended pam message '%s'", GDM_PAM_EXTENSION_CHOICE_LIST);

                GDM_PAM_EXTENSION_CHOICE_LIST_RESPONSE_INIT (list_response);

                res = gdm_session_worker_process_choice_list_request (worker, list_request, list_response);

                if (! res) {
                        g_free (list_response);
                        return FALSE;
                }

                *response = GDM_PAM_EXTENSION_MESSAGE_TO_PAM_REPLY (list_response);
                return TRUE;
        } else {
                g_debug ("GdmSessionWorker: received extended pam message of unknown type %u", (unsigned int) extended_message->type);
                return FALSE;

        }

        return TRUE;
}
gdm_session_worker_process_extended_pam_message (GdmSessionWorker          *worker,
                                                 const struct pam_message  *query,
                                                 char                     **response)
{
        GdmPamExtensionMessage *extended_message;
        gboolean res;

        extended_message = GDM_PAM_EXTENSION_MESSAGE_FROM_PAM_MESSAGE (query);

        if (GDM_PAM_EXTENSION_MESSAGE_TRUNCATED (extended_message)) {
                g_warning ("PAM service requested binary response for truncated query");
                return FALSE;
        }

        if (GDM_PAM_EXTENSION_MESSAGE_INVALID_TYPE (extended_message)) {
                g_warning ("PAM service requested binary response for unadvertised query type");
                return FALSE;
        }

        if (GDM_PAM_EXTENSION_MESSAGE_MATCH (extended_message, worker->priv->extensions, GDM_PAM_EXTENSION_CHOICE_LIST)) {
                GdmPamExtensionChoiceListRequest *list_request = (GdmPamExtensionChoiceListRequest *) extended_message;
                GdmPamExtensionChoiceListResponse *list_response = malloc (GDM_PAM_EXTENSION_CHOICE_LIST_RESPONSE_SIZE);

                g_debug ("GdmSessionWorker: received extended pam message '%s'", GDM_PAM_EXTENSION_CHOICE_LIST);

                GDM_PAM_EXTENSION_CHOICE_LIST_RESPONSE_INIT (list_response);

                res = gdm_session_worker_process_choice_list_request (worker, list_request, list_response);

                if (! res) {
                        g_free (list_response);
                        return FALSE;
                }

                *response = GDM_PAM_EXTENSION_MESSAGE_TO_PAM_REPLY (list_response);
                return TRUE;
        } else {
                g_debug ("GdmSessionWorker: received extended pam message of unknown type %u", (unsigned int) extended_message->type);
                return FALSE;

        }

        return TRUE;
}