Important: The information in this document is obsolete and should not be used for new development.
Implementing Your Cyberdog Panel Parts
You can associate a Connect To and a Preferences panel with your Cyberdog service. The Connect To panel is an OpenDoc part that is associated with aCyberConnectExtensionobject. A Preferences panel is an OpenDoc part that is associated with aCyberPreferencesExtensionobject. You implement these parts and extensions just as you implement a Cyberdog display part. See Chapter 4, "Creating a Cyberdog Display Part," in Cyberdog Programmer's Kit for information about implementing display parts and part extensions. The following sections show you the additional steps that you must take to implement these panels.Creating the Connect To Panel
To create a Connect To panel, you must implement the OpenDoc extension protocol in the part that displays your Connect To panel (see "Creating a Cyberdog Display Part"), override the extension'sCreateCyberItemmethod, and set up the part's name-mapping ('nmap') resource.You override the extension's
CreateCyberItemmethod to create your Cyberdog item using the fields in the Connect To panel. Listing 29 shows the Connect To extension'sCreateCyberItemmethod for the Finger service.Listing 29 The Connect To extension's
CreateCyberItemmethod for the Finger service
CyberItem* FSConnect::CreateCyberItem(Environment* ev) { CyberItem* ci = nil; if (fHostTE) { Str255 Str, uStr, url; // Convert the text to pascal strings; truncate if necessary. GetDialogItemText((Handle)TEGetText(fHostTE), hStr); GetDialogItemText((Handle)TEGetText(fUserTE), uStr); // Concatenate the strings into Finger format. MakeFingerURL(uStr, hStr, url); // Create the Cyberdog item. ci = GetCyberSession(ev)->CreateCyberItemFromURL(ev, (char*)url); } return ci; }Your panel part's name-mapping ('nmap') resource specifies the panel's ID and kind. The service uses the part's kind to locate the panel that matches the panel specified in the service resource. See "Defining Your Cyberdog Service Resource" (page 6) for information about the service resource. Listing 30 shows the name-mapping resource for the Connect To panel associated with the Finger service. The panel's ID is kFSConnectID, and its kind is kFingerConnectPanelKind.Listing 30 The Connect To panel's resource for the Finger service
resource kODNameMappings (kEditorKindMapId) { kODEditorKinds, { /* array Types: 2 elements */ /* [1] */ kFSConnectID, kODIsAnISOStringList { { /* array ClassIDs: 1 element */ /* [4] */ kFingerConnectPanelKind } } } };Creating the Preferences Panel
To create a Preferences panel, you must implement the OpenDoc extension protocol in the part that displays your Preferences panel and set up the part's name-mapping ('nmap') resource. These are same tasks you perform to create a Connect To panel, except that you associate your panel's display part with aCyberPreferencesExtensionobject.Typically, you store preferences in the Internet Config file. To handle reading and writing to Internet Config, you must override the
InternalizeICandExternalizeICmethods, respectively, of your preferences extension. TheInternalizeICmethod is called to retrieve preferences when the extension is created. TheExternalizeICmethod is called to save preferences when the extension is removed.The Preferences panel part for the Finger service uses Internet Config to store preferences. The
InternalizeICandExternalizeICmethods of the preferences extension pass control to methods of the same name in the panel part. Listing 31 shows the panel part'sInternalizeICmethod, which reads the preference associated with kFingerOpenAsyncPref from Internet Config.Listing 31 The
InternalizeICmethod of the Preferences panel part
void FSPrefs::InternalizeIC(Environment* ev, ICInstance inst) { ICError err; ICAttr icAttr; long size; Boolean checkValue; do { err = ICBegin(inst, icReadOnlyPerm); if (err != noErr) break; // Use the Open Asynch checkbox. size = sizeof(ODBoolean); err = ICGetPref (inst, kFingerOpenAsyncPref, &icAttr, (Ptr)&checkValue, &size); if (err == noErr) fCheckBoxOn = checkValue; else if (err != icPrefNotFoundErr) break; } while (0); err = ICEnd(inst); if (err != noErr) DebugStr("\p InternalizeIC error"); }Listing 32 shows the panel part'sExternalizeICmethod, which writes the preference associated with kFingerOpenAsyncPref from Internet Config.Listing 32 The
ExternalizeICmethod of the Preferences panel part
void FSPrefs::ExternalizeIC(Environment* ev, ICInstance inst) { ICError err; Boolean checkValue; do { err = ICBegin(inst, icReadWritePerm); if (err != noErr) break; // Use the Open Asynch checkbox. checkValue = fCheckBoxOn; err = ICSetPref(inst, kFingerOpenAsyncPref, ICattr_no_change, (Ptr)&checkValue, sizeof(ODBoolean)); if (err != noErr) break; } while (0); err = ICEnd(inst); if (err != noErr) DebugStr("\p ExternalizeIC error"); }The constants kFingerCreator andkFingerOpenAsyncPrefare defined as follows:
#define kFingerCreator 'FNGR' #define kFingerOpenAsyncPref"\p464E4752OpenAsync"/* ODBoolean */The464E4752in the definition forkFingerOpenAsyncPrefis the hexadecimal representation of'FNGR'. All keys in Internet Config that are not defined inICKeys.hshould begin with the hexadecimal representation (four hexadecimal digits) of the creator type.