Exemple #1
0
/*
 * Load the actions attributes
 */
int
gilP_load_att_actions(FILE * inFile, ABObj obj, ABObj module)
{
    int                 return_value = 0;
    int                 rc = 0; /* r turn code */
    ABObj               action = NULL;

    if (!abio_get_list_begin(inFile))
        return (abil_print_load_err(ERR_WANT_LIST), -1);

    while (!abio_get_list_end(inFile))
    {
        action = obj_create(AB_TYPE_ACTION, NULL);

        if ((rc = get_action(inFile, obj, module, action)) < 0)
        {
            obj_destroy(action);
            return rc;
        }
        else
        {
	    if (obj_get_when(action) == AB_WHEN_UNDEF)
	    {
		/* unsupported :when value - ignore it and continue */
		obj_destroy(action);
	    }
	    else
	    {
                install_action(obj, module, action);
	    }
        }
    }
    return return_value;
}
Exemple #2
0
static int
write_main_session_restore(
    GenCodeInfo	genCodeInfo, 
    ABObj	project
)
{
    File	codeFile;

    if (!genCodeInfo || !project)
	return (0);

    codeFile = genCodeInfo->code_file;

    if (abmfP_proj_needs_session_restore(project))
    {
        AB_TRAVERSAL	trav;
	ABObj		action;
	char		*ss_restore_CB_name = NULL;

        abio_puts(codeFile,"\n");
        abio_puts(codeFile,"if (dtb_app_resource_rec.session_file)\n");
        abio_puts(codeFile,"{\n");

	if (!obj_is_project(project))
	    project = obj_get_project(project);

	/*
	 * Search for session restore callback in project
	 * action list
	 */
    	for (trav_open(&trav, project, AB_TRAV_ACTIONS);
             (action = trav_next(&trav)) != NULL;)
    	{
	    switch(obj_get_when(action))
	    {
		case AB_WHEN_SESSION_RESTORE:
		    /*
		     * Remember session restore callback if found
		     */
		    ss_restore_CB_name = obj_get_func_name(action);
		    break;
		default:
		    break;
	    }
	}
	trav_close(&trav);

	abio_printf(codeFile, 
	"    dtb_set_client_session_restoreCB((DtbClientSessionRestoreCB)%s);\n",
		ss_restore_CB_name ? ss_restore_CB_name : "NULL");

        abio_puts(codeFile,
	"    (void)dtb_session_restore(toplevel, dtb_app_resource_rec.session_file);\n");
        abio_puts(codeFile,"}\n");

        abio_puts(codeFile,"\n");
    }

    return (0);
}
Exemple #3
0
static int
write_tooltalk_cb_vars(
    GenCodeInfo genCodeInfo,
    ABObj action
)
{
    File                codeFile;

    if (!genCodeInfo || !action)
        return 0;

    codeFile = genCodeInfo->code_file;

    switch(obj_get_when(action))
    {
    case AB_WHEN_TOOLTALK_QUIT:
        abio_puts(codeFile, "int\t\tsilent = 0;\n");
        abio_puts(codeFile, "int\t\tforce = 0;\n");
        abio_puts(codeFile, "Boolean\t\tcancel = False;\n");
        break;
    case AB_WHEN_TOOLTALK_GET_STATUS:
        abio_puts(codeFile, "char\t\t*status_string = \"\";\n");
        break;
    case AB_WHEN_TOOLTALK_PAUSE_RESUME:
        abio_puts(codeFile, "Boolean\t\tsensitive = (Bool)calldata;\n");
        abio_puts(codeFile, "Boolean\t\talready_set = False;\n");
        break;
    case AB_WHEN_TOOLTALK_DO_COMMAND:
        abio_puts(codeFile, "Tt_status\t\tstatus = TT_DESKTOP_ENOTSUP;\n");
        abio_puts(codeFile, "char\t\t*command;\n");
        abio_puts(codeFile, "char\t\t*result;\n");
        break;
    default:
        break;
    }
    return 0;
}
Exemple #4
0
static int
write_ss_cb_vars(
    GenCodeInfo genCodeInfo,
    ABObj action
)
{
    File                codeFile;

    if (!genCodeInfo || !action)
        return 0;

    codeFile = genCodeInfo->code_file;

    switch(obj_get_when(action))
    {
    case AB_WHEN_SESSION_SAVE:
    case AB_WHEN_SESSION_RESTORE:
        abio_puts(codeFile, "Boolean\t\tret_value = False;\n");
        break;
    default:
        break;
    }
    return 0;
}
Exemple #5
0
static int 	
write_main_register_save_yourself(
			GenCodeInfo	genCodeInfo, 
			ABObj		project, 
			char		*atom_name
)
{
    File	codeFile;

    if (!genCodeInfo || !project)
	return (0);

    if (!atom_name)
	atom_name = "save_yourself_atom";

    codeFile = genCodeInfo->code_file;

    abio_puts(codeFile,"\n");

    /*
     * Set client save session callback
     */
    if (abmfP_proj_needs_session_save(project))
    {
        AB_TRAVERSAL	trav;
	ABObj		action;
	char		*ss_save_CB_name = NULL;

	/*
	 * Search for session save callback in project
	 * action list
	 */
    	for (trav_open(&trav, project, AB_TRAV_ACTIONS);
             (action = trav_next(&trav)) != NULL;)
    	{
	    switch(obj_get_when(action))
	    {
		case AB_WHEN_SESSION_SAVE:
		    /*
		     * Remember session save callback if found
		     */
		    ss_save_CB_name = obj_get_func_name(action);
		    break;
		default:
		    break;
	    }
	}
	trav_close(&trav);

	abio_printf(codeFile, 
	    "dtb_set_client_session_saveCB((DtbClientSessionSaveCB)%s);\n",
		ss_save_CB_name ? ss_save_CB_name : "NULL");

	abio_puts(codeFile, "\n");
    }

    abio_printf(codeFile,"XmAddWMProtocolCallback(toplevel, %s,\n", atom_name);
    abio_puts(codeFile,"\tdtb_session_save, (XtPointer)NULL);\n");

    abio_puts(codeFile,"\n");

    return (0);
}
Exemple #6
0
static int
write_main_tooltalk_init(
    GenCodeInfo genCodeInfo, 
    ABObj project 
) 
{ 
    AB_TOOLTALK_LEVEL	tt_level;
    AB_TRAVERSAL	trav;
    STRING		vendor, version;
    ABObj		action;
    File        	codeFile; 
    int         	ret_val = 0; 
 
    if (!genCodeInfo || !project ||
        (tt_level = obj_get_tooltalk_level(project)) == AB_TOOLTALK_NONE)
        return 0;
 
    codeFile = genCodeInfo->code_file; 

    abio_puts(codeFile, abmfP_comment_begin);
    abio_puts(codeFile, abmfP_comment_continue);
    abio_puts(codeFile, "Initialize ToolTalk to handle Desktop Message Protocol\n");
    abio_puts(codeFile, abmfP_comment_end);

    if (tt_level == AB_TOOLTALK_DESKTOP_ADVANCED)
    {
    	for (trav_open(&trav, project, AB_TRAV_ACTIONS);
             (action = trav_next(&trav)) != NULL;)
    	{
	    switch(obj_get_when(action))
	    {
		case AB_WHEN_TOOLTALK_QUIT:
		    abio_printf(codeFile, "dtb_set_tt_msg_quitCB((DtbTTMsgHandlerCB)%s);\n",
			obj_get_func_name(action));
		    break;
		case AB_WHEN_TOOLTALK_DO_COMMAND:
                    abio_printf(codeFile, "dtb_set_tt_msg_do_commandCB((DtbTTMsgHandlerCB)%s);\n", 
                        obj_get_func_name(action)); 
                    break; 
                case AB_WHEN_TOOLTALK_GET_STATUS: 
                    abio_printf(codeFile, "dtb_set_tt_msg_get_statusCB((DtbTTMsgHandlerCB)%s);\n",  
                        obj_get_func_name(action));  
                    break; 
                case AB_WHEN_TOOLTALK_PAUSE_RESUME:
                    abio_printf(codeFile, "dtb_set_tt_msg_pause_resumeCB((DtbTTMsgHandlerCB)%s);\n",  
                        obj_get_func_name(action));
                    break;
		default:
		    break;
	    }
	}
	trav_close(&trav);
	abio_puts(codeFile, "\n");
    }

    /* Write out tt init code to deal with possible remote display session */
    abio_puts(codeFile, "ttenv = getenv(\"TT_SESSION\");\n");
    abio_puts(codeFile, "if (!ttenv || strlen(ttenv) == 0)\n");
    abio_indent(codeFile);
    abio_puts(codeFile,"ttenv = getenv(\"_SUN_TT_SESSION\");\n");
    abio_outdent(codeFile);
    abio_puts(codeFile, "if (!ttenv || strlen(ttenv) == 0)\n");
    abmfP_write_c_block_begin(genCodeInfo);
    abio_puts(codeFile, "session = tt_X_session(XDisplayString(display));\n");
    abio_puts(codeFile, "tt_default_session_set(session);\n");
    abio_puts(codeFile, "tt_free(session);\n");
    abmfP_write_c_block_end(genCodeInfo);
    
    abio_printf(codeFile, "tt_proc_id = ttdt_open(&tt_fd, \"%s\", ",
	obj_get_name(project));
    vendor = obj_get_vendor(project);
    version = obj_get_version(project);
    abio_printf(codeFile, "\"%s\", \"%s\", 1);\n",
	vendor? vendor : "NULL", version? version : "NULL");
    abio_puts(codeFile, "tt_status = tt_ptr_error(tt_proc_id);\n");
    abio_puts(codeFile, "if (tt_status != TT_OK)\n");
/*
    abio_puts(codeFile, "{\n");
    abio_indent(codeFile);
*/
    abmfP_write_c_block_begin(genCodeInfo);
    abio_puts(codeFile, 
	"fprintf(stderr,\"ttdt_open(): %s\\n\", tt_status_message(tt_status));\n");
    abio_puts(codeFile, "tt_proc_id = NULL;\n");
/*
    abio_outdent(codeFile);
    abio_puts(codeFile, "}\n");
*/
    abmfP_write_c_block_end(genCodeInfo); 
    abio_puts(codeFile, "else\n");
/*
    abio_puts(codeFile, "{\n");
    abio_indent(codeFile);
*/
    abmfP_write_c_block_begin(genCodeInfo);
    abio_puts(codeFile, "XtAppAddInput(app, tt_fd, (XtPointer)XtInputReadMask,\n");
    abio_indent(codeFile);
    abio_puts(codeFile, "tttk_Xt_input_handler, tt_proc_id);\n\n");
    abio_outdent(codeFile); 
    abio_printf(codeFile, "tt_session_pattern = ttdt_session_join(NULL, %s,\n",
	tt_level == AB_TOOLTALK_DESKTOP_ADVANCED? "dtb_tt_contractCB" : "NULL");
    abio_indent(codeFile);
    abio_puts(codeFile, "toplevel, NULL, True);\n\n");
    abio_outdent(codeFile);
    abio_puts(codeFile, "atexit(dtb_tt_close);\n");
/*
    abio_outdent(codeFile); 
    abio_puts(codeFile, "}\n");
*/
    abmfP_write_c_block_end(genCodeInfo);  

    return 0;

}
Exemple #7
0
static int
write_ss_cb_body1(
    GenCodeInfo genCodeInfo,
    ABObj action
)
{
    File                codeFile;

    if (!genCodeInfo || !action)
        return 0;

    codeFile = genCodeInfo->code_file;

    switch(obj_get_when(action))
    {
    case AB_WHEN_SESSION_RESTORE:
        abio_puts(codeFile, abmfP_comment_begin);
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "Restore application state via session file.\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "Use contents of \"session file\" to bring the application\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "to the desired state.\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "Set \"ret_value\" to True to indicate success.\n");
        abio_puts(codeFile, abmfP_comment_end);
        break;
    case AB_WHEN_SESSION_SAVE:
        abio_puts(codeFile, abmfP_comment_begin);
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "Save application state in either session file and/or\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "command line vector.\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile, "\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "Session File:\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "    Open the file \"session_file\"\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "    Write application state information into it\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "    Close the file\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "    Set \"ret_value\" to True\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "    (Setting \"ret_value\" to True is important if you are using\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "    session files! Do not set it to True if you are not using\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "    session files.)\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,   "\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "Command line vector:\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "    Allocate an argv vector\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "    Fill it up with the appropriate strings\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "    Return the argv vector in \"argv\" i.e.\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "    \t*argv = my_new_argv;\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "    Return the size of the vector in argc\n");
        abio_puts(codeFile, abmfP_comment_end);
        break;
    default:
        break;
    }
    abio_puts(codeFile, "\n");
    return 0;
}
Exemple #8
0
static int
write_tooltalk_cb_body2(
    GenCodeInfo genCodeInfo,
    ABObj action
)
{
    File                codeFile;

    if (!genCodeInfo || !action)
        return 0;

    codeFile = genCodeInfo->code_file;

    abio_puts(codeFile, "\n");

    switch(obj_get_when(action))
    {
    case AB_WHEN_TOOLTALK_QUIT:
        abio_puts(codeFile, "if (cancel == True)\n");
        abio_indent(codeFile);
        abio_puts(codeFile, "tttk_message_fail(msg, TT_DESKTOP_ECANCELED, 0, 1);\n");
        abio_outdent(codeFile);
        abio_puts(codeFile, "else\n");
        abio_puts(codeFile, "{\n");
        abio_indent(codeFile);
        write_tooltalk_msg_reply(codeFile);
        abio_puts(codeFile, "\n");

        abmfP_write_c_comment(genCodeInfo, FALSE,
                              "Now that the Message has been replied, process Quit operation");
        abmfP_write_user_code_seg(genCodeInfo, NULL);
        abio_puts(codeFile, nlstr);

        abio_outdent(codeFile);
        abio_puts(codeFile, "}\n");
        break;
    case AB_WHEN_TOOLTALK_GET_STATUS:
        abio_puts(codeFile, "tt_message_arg_val_set(msg, 0, status_string);\n");
        write_tooltalk_msg_reply(codeFile);
        break;
    case AB_WHEN_TOOLTALK_PAUSE_RESUME:
        abio_puts(codeFile, "if (already_set == True)\n");
        abio_indent(codeFile);
        abio_puts(codeFile, "tt_message_status_set(msg, TT_DESKTOP_EALREADY);\n");
        abio_outdent(codeFile);
        write_tooltalk_msg_reply(codeFile);
        break;
    case AB_WHEN_TOOLTALK_DO_COMMAND:
        abio_puts(codeFile, "tt_free(command);\n");
        abio_puts(codeFile, "tt_message_status_set(msg, status);\n");
        abio_puts(codeFile, "if (tt_is_err(status))\n");
        abio_indent(codeFile);
        abio_puts(codeFile, "tttk_message_fail(msg, status, 0, 1);\n");
        abio_outdent(codeFile);
        abio_puts(codeFile, "else\n");
        abio_puts(codeFile, "{\n");
        abio_indent(codeFile);
        abio_puts(codeFile, "if (result != NULL)\n");
        abio_indent(codeFile);
        abio_puts(codeFile, "tt_message_arg_val_set(msg, 1, result);\n");
        abio_outdent(codeFile);
        write_tooltalk_msg_reply(codeFile);
        abio_outdent(codeFile);
        abio_puts(codeFile, "}\n");
        break;
    default:
        break;
    }

    abio_puts(codeFile, nlstr);
    abmfP_write_user_code_seg(genCodeInfo, NULL);
    abio_puts(codeFile, nlstr);
    abio_puts(codeFile, "return True;\n");
    return 0;
}
Exemple #9
0
static int
write_tooltalk_cb_body1(
    GenCodeInfo genCodeInfo,
    ABObj action
)
{
    File                codeFile;

    if (!genCodeInfo || !action)
        return 0;

    codeFile = genCodeInfo->code_file;

    switch(obj_get_when(action))
    {
    case AB_WHEN_TOOLTALK_QUIT:
        abio_puts(codeFile, "tt_message_arg_ival(msg, 0, &silent);\n");
        abio_puts(codeFile, "tt_message_arg_ival(msg, 1, &force);\n");
        abio_puts(codeFile,"\n");
        abio_puts(codeFile, abmfP_comment_begin);
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "Process Quit request->\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "if \"silent\" == 1, then the Quit should occur without\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "notifying the user.  If \"force\" == 1, then the user may\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "be notified, but the Quit should not be cancellable.\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "If \"silent\" == 0 and \"force\" == 0, then this Quit\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "request may be cancelled, in which case \"cancel\" should\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "be set to True in order send the \"failed\" reply.\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "If the Quit request is honored (not cancelled), the\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "application exit should not occur until after the request\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "has been replied-to.\n");
        abio_puts(codeFile, abmfP_comment_end);
        break;

    case AB_WHEN_TOOLTALK_GET_STATUS:
        abio_puts(codeFile, abmfP_comment_begin);
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "Process Get Status request->\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "The application should assign \"status_string\" an appropriate\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "string value reflecting the application's status.\n");
        abio_puts(codeFile, abmfP_comment_end);
        break;
    case AB_WHEN_TOOLTALK_PAUSE_RESUME:
        abio_puts(codeFile, abmfP_comment_begin);
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "Process Pause/Resume request->\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "If \"sensitive\" == False (Pause), then the application should\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "set the sensitivity on all mapped shells to False.  If\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "\"sensitive\" == True (Resume), then the application should\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "set the sensitivity on all mapped shells to True.n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "If the application is already in the requested state of\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "sensitivity, then \"already_set\" should be set to True.\n");
        abio_puts(codeFile, abmfP_comment_end);
        break;
    case AB_WHEN_TOOLTALK_DO_COMMAND:
        abio_puts(codeFile, "command = tt_message_arg_val(msg, 0);\n");
        abio_puts(codeFile, "\n");
        abio_puts(codeFile, abmfP_comment_begin);
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "Process Do_Command request->\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "The application should execute the code defined by \"command\".\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "If execution is successful, then \"status\" should be set to TT_OK,\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "else set to the appropriate Tt_status value.\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "If the command returns a result, then \"result\" should be set\n");
        abio_puts(codeFile, abmfP_comment_continue);
        abio_puts(codeFile,
                  "to the appropriate result string.\n");
        abio_puts(codeFile, abmfP_comment_end);
        break;
    default:
        break;
    }
    abio_puts(codeFile, "\n");
    return 0;
}
Exemple #10
0
int
abmfP_write_action_function(
    GenCodeInfo	genCodeInfo,
    ABObj		action
)
{
    int			rc = 0;			/* return code */
    BOOL		isTTCB = FALSE;
    BOOL		ss_cb = FALSE;
    File                codeFile = genCodeInfo->code_file;
    BOOL		topUserSegWritten = FALSE;
    BOOL		bottomUserSegWritten = FALSE;
    BOOL		funcBodyWritten = FALSE;
    BOOL		funcEndWritten = FALSE;
    BOOL		actionPrintfWritten = FALSE;
    int                 return_value = 0;
    ABObj               fromObj = obj_get_from(action);
    ABObj		actualFromObj = NULL;
    ABObj		toObj = obj_get_to(action);
    ABObj		module = NULL;
    char		actionName[1024];
    char		actionPrintf[1024];

    abmfP_gencode_enter_func(genCodeInfo);
    abmfP_ip_obj(genCodeInfo) = obj_get_to(action);
    util_strncpy(actionName, abmfP_get_action_name(action), 1024);
    sprintf(actionPrintf, "printf(\"action: %s()\\n\");\n", actionName);

    /***
     *** START OF FUNCTION
     ***/

    switch (obj_get_when(action))
    {
    case AB_WHEN_AFTER_CREATED:
        /*
         * post-create procs have the signature of an Xt Callback,
         * although they are called as conventional functions.
         */
        fromObj = obj_get_from(action);
        actualFromObj = get_actual_from_obj(action);
        abmfP_write_xm_callback_begin(genCodeInfo, FALSE, actionName);
        write_instance_ptr_var(genCodeInfo, actualFromObj,
                               get_from_var_name(), "callData", TRUE, NULL);
        abio_puts(genCodeInfo->code_file, nlstr);

        break;

    case AB_WHEN_DRAGGED_FROM:
    {
        abio_printf(genCodeInfo->code_file,
                    abmfP_lib_default_dragCB->def,	/* this is a format string */
                    actionName,actionName,actionName,
                    actionName,actionName, actionName);
        abio_puts(genCodeInfo->code_file, "\n\n");

        /* these are all in the "library" definition */
        topUserSegWritten = TRUE;
        bottomUserSegWritten = TRUE;
        funcBodyWritten = TRUE;
        funcEndWritten = TRUE;
        actionPrintfWritten = TRUE;
    }
    break;

    case AB_WHEN_DROPPED_ON:
    {
        abio_printf(genCodeInfo->code_file,
                    abmfP_lib_default_dropCB->def,	/* this is a format string */
                    actionName,actionName,actionName,actionName);
        abio_puts(genCodeInfo->code_file, "\n\n");

        /* these are all in the "library" definition */
        topUserSegWritten = TRUE;
        bottomUserSegWritten = TRUE;
        funcBodyWritten = TRUE;
        funcEndWritten = TRUE;
        actionPrintfWritten = TRUE;
    }
    break;

    case AB_WHEN_TOOLTALK_QUIT:
    case AB_WHEN_TOOLTALK_DO_COMMAND:
    case AB_WHEN_TOOLTALK_GET_STATUS:
    case AB_WHEN_TOOLTALK_PAUSE_RESUME:
        isTTCB = TRUE;
        abio_printf(codeFile, begin_tt_callback_body, actionName);
        abmfP_write_c_block_begin(genCodeInfo);
        write_tooltalk_cb_vars(genCodeInfo, action);
        break;

    case AB_WHEN_SESSION_RESTORE:
        ss_cb = TRUE;
        abio_printf(codeFile, begin_ss_restore_callback_body,
                    abmfP_get_action_name(action));
        abmfP_write_c_block_begin(genCodeInfo);
        write_ss_cb_vars(genCodeInfo, action);
        break;

    case AB_WHEN_SESSION_SAVE:
        ss_cb = TRUE;
        abio_printf(codeFile, begin_ss_save_callback_body,
                    abmfP_get_action_name(action));
        abmfP_write_c_block_begin(genCodeInfo);
        write_ss_cb_vars(genCodeInfo, action);
        break;

    default:
        abmfP_write_xm_callback_begin(genCodeInfo, FALSE, actionName);
        break;

    } /* switch obj_get_when() */


    /*****
     ***** TOP USER SEGMENT
     *****/

    if (!topUserSegWritten)
    {
        STRING	contents =
            (actionPrintfWritten? NULL:(isTTCB? actionPrintf:NULL));
        abmfP_write_user_var_and_code_seg(genCodeInfo, contents);
        abio_puts(codeFile, nlstr);
        topUserSegWritten = TRUE;
        if (contents != NULL)
        {
            actionPrintfWritten = TRUE;
        }
    }

    /***
     *** FUNCTION BODY
     ***/

    if (isTTCB)
    {
        write_tooltalk_cb_body1(genCodeInfo, action);
        abmfP_write_user_code_seg(genCodeInfo, NULL);
        write_tooltalk_cb_body2(genCodeInfo, action);
        funcBodyWritten = TRUE;
        bottomUserSegWritten = TRUE;
    }
    else if (ss_cb)
    {
        write_ss_cb_body1(genCodeInfo, action);
        abmfP_write_user_code_seg(genCodeInfo, NULL);
        write_ss_cb_body2(genCodeInfo, action);
        funcBodyWritten = TRUE;
        bottomUserSegWritten = TRUE;
    }
    else if (!funcBodyWritten) switch (obj_get_func_type(action))
        {
        case AB_FUNC_BUILTIN:
            rc = abmfP_write_builtin_action(genCodeInfo, action, TRUE);
            return_if_err(rc,rc);
            funcBodyWritten = TRUE;
            break;

        case AB_FUNC_USER_DEF:
            abmfP_write_user_start_comment(genCodeInfo, "vvv Add C code below vvv");
            abmfP_write_user_end_comment(genCodeInfo, "^^^ Add C code above ^^^");
            bottomUserSegWritten = TRUE;
            funcBodyWritten = TRUE;
            break;

        case AB_FUNC_CODE_FRAG:
            abio_puts(codeFile, obj_get_func_code(action));
            funcBodyWritten = TRUE;
            break;

        case AB_FUNC_ON_ITEM_HELP:
            abio_printf(codeFile, "dtb_do_onitem_help();\n");
            funcBodyWritten = TRUE;
            break;

        case AB_FUNC_HELP_VOLUME:
            abio_printf(codeFile,
                        "dtb_show_help_volume_info(\"%s\", \"%s\");\n",
                        istr_string(action->info.action.volume_id),
                        istr_string(action->info.action.location));
            funcBodyWritten = TRUE;
            break;

        default:
        {
            char *obj_name_string = obj_get_name(fromObj);
            util_printf_err(catgets(Dtb_project_catd, 1, 78,
                                    "unknown function type for action from object, %s"),
                            obj_name_string);
            return_code(ERR);
        }
        break;
        }

    /*****
     ***** BOTTOM USER SEGMENT
     *****/

    if (!bottomUserSegWritten)
    {
        STRING	contents = (actionPrintfWritten? NULL:actionPrintf);
        abmfP_write_user_code_seg(genCodeInfo, contents);
        bottomUserSegWritten = TRUE;
        if (contents != NULL)
        {
            actionPrintfWritten = TRUE;
        }
    }

    /*****
     ***** FUNCTION END
     *****/

    if (!funcEndWritten)
    {
        abmfP_write_c_func_end(genCodeInfo, NULL);
        funcEndWritten = TRUE;
    }

epilogue:
    abmfP_gencode_exit_func(genCodeInfo);
    return return_value;
}