Common Desktop Environment: ToolTalk Messaging Overview

Tasks ToolTalk-aware Editor Applications Need to Perform

In addition to the duties described in the section "Tasks Every ToolTalk-aware Application Needs to Perform", ToolTalk-aware editor applications also need to perform other tasks, including:

This section provides examples of the ToolTalk code you need to include in your editor application so that it can perform these additional tasks.

Note -

The code snippets used in this section are taken from the CoEditor.C file. This file contains specific commands for editor applications. See Appendix B, The CoEd Demonstration Program for the detailed source code.

Writing a Media Load Pattern Callback

There is one step you need to perform before you code your editor application to include any ToolTalk functions: you need to write a media load pattern callback routine. For example,

Tt_message CoEditor::loadISOLatin1_(     Tt_message       msg,     void              *pWidget,
     Ttttk_op          op,     Tt_status        diagnosis,     unsigned char     *contents,
     int               len,     char              *file,     char              *docname   )

This callback is passed to the media load function at runtime.

Declaring a Ptype

Since type information is specified only once (when your application is installed), your application needs to only declare its ptype each time it starts.

Passing Media Load Pattern Callbacks

The media load pattern callback routine you wrote previously is passed in at runtime. The callbacks are registered when your application joins the session. When your tool agrees to handle a request, a callback message is sent. A callback message is also sent if a file is joined or if a message is failed.

// Join the session and register patterns and callbacks 
sessPats = ttdt_session_join( 0, 0, session_shell, this, 1 );  

// Accept responsibility to handle a request
    _contractPats = ttdt_message_accept(msg, CoEditor::_contractCB_, shell, this, 1, 1 ); 

 // Optional task: Join a file (Can be called recursively)
    if (_filePats == 0) {_filePats = ttdt_file_join( _file, TT_SCOPE_NONE, 1,
                     CoEditor::_fileCB_, this );

// Fail a message 
tttk_message_fail( msg, TT_DESKTOP_ENODATA, 0, 1 );

Replying When Request Is Completed

After your application has completed the operation request, it must reply to the sending application. The following message returns the edited contents of text to the sender.

// Reply to media load pattern callback 
// with edited contents of text 
ttmedia_load_reply( _contract, (unsigned char *)contents,
                 len, 1 );