The following steps will create a basic EETransfer client application. This application is able to connect to a remote server and either send all the files pending in the Newton OutBox, or receive all the files available on the server. Basic Setup * Create a project. * In NTK's Project Settings dialog, set Platform to "Newton 2.1" or "Newton 2.0". * Add the following text files to the project (they are located in the EEIncludes folder). EEFileConstants.f EERecodeConstants.f EETransferConstants.f Create the base view * Create a layout file. * Drag out a protoApp. * Set the following slots to the following values: EETransfer_DoReceiveScript: func() begin // This method is automatically called by EETransfer, when // the user clicks the Receive button // Don't change its name. // The slots defined in scriptGlobals are shared by all // the instructions of the script. local scriptGlobals := { charset: kUnixCharset, // Defined in EERecodeConstants.f endpoint: nil, // will be inited by the ConnectModem instruction transport: nil, // will be inited automatically }; local scriptInstruction := [ { // Initiate the modem connection. toolSymbol: 'ConnectModem, phoneNumber: phoneNumber, }, // If any of the following instructions fail, the script execution // will abort and EETransfer will automatically disconnect. { // Wait for the string "login". toolSymbol: 'WaitForString, string: "login", timeout: 15000, // If the string "login" is not received after 15 seconds, // the script execution will abort, }, { // Send your login toolSymbol: 'SendString, string: login & unicodeCR, }, { // Wait for the string "password". toolSymbol: 'WaitForString, string: "assword", timeout: 15000, }, { // Send your password toolSymbol: 'SendString, string: password & unicodeCR, isSecret: true, // The password will be hidden. }, { // Wait for the $ character (Unix prompt). toolSymbol: 'WaitForString, string: "$", timeout: 15000, }, { // Receive all the files in the current directory (the "sz *" command will be executed by the remote server). toolSymbol: 'ReceiveZModem, szString: "sz *" & unicodeCR }, // EETransfer will automatically disconnect. No instructions needed. ]; // Execute the script and then call base:HandleReceivedFiles(). TransportNotify(kEETransferTransportSymbol, 'Execute, [ scriptInstruction, scriptGlobals, base, 'HandleReceivedFiles, ]); end EETransfer_DoSendScript: func() begin // This method is automatically called by EETransfer, when // the user clicks the Send button // Don't change its name. // The slots defined in scriptGlobals are shared by all // the instructions of the script. local scriptGlobals := { charset: kUnixCharset, // Defined in EERecodeConstants.f endpoint: nil, // will be inited by the ConnectModem instruction transport: nil, // will be inited automatically }; local scriptInstruction := [ { // Initiate the modem connection. toolSymbol: 'ConnectModem, phoneNumber: phoneNumber, }, // If any of the following instructions fail, the script execution // will abort and EETransfer will automatically disconnect. { // Wait for the string "login". toolSymbol: 'WaitForString, string: "login", timeout: 15000, // If the string "login" is not received after 15 seconds, // the script execution will abort, }, { // Send your login toolSymbol: 'SendString, string: login & unicodeCR, }, { // Wait for the string "password". toolSymbol: 'WaitForString, string: "assword", timeout: 15000, }, { // Send your password toolSymbol: 'SendString, string: password & unicodeCR, isSecret: true, // The password will be hidden. }, { // Wait for the $ character (Unix prompt). toolSymbol: 'WaitForString, string: "$", timeout: 15000, }, { // Send all the files pending in the OutBox. toolSymbol: 'SendZModem, }, // EETransfer will automatically disconnect. No instructions needed. ]; // Execute the script. TransportNotify(kEETransferTransportSymbol, 'Execute, [ scriptInstruction, scriptGlobals, nil, nil, ]); end HandleReceivedFiles: func(result) begin // This method is called after the script defined by // EETransfer_DoReceiveScript has been executed. // result can have one of the following values: // 'ok The script has been completed successfully // 'warning A minor error occured during the script execution // For example: * the modem is not connected // * a timeout during a WaitForString // // 'error A critical error occured during the script execution // For example: * wrong or missing option in a script instruction // 'cancelled The script execution has been cancelled, either by the user // (by clicking the Stop button) or by the remote computer if result <> 'ok then return; // Parse all the received files in the InBox and notify the user of its existence. local ioBox := GetRoot().ioBox; local ioBoxItemsSpec := ioBox:GetSpec('transport, nil, kEETransferTransportSymbol); local inBoxCursor := ioBox:MakeCursor('inBox, ioBoxItemsSpec); local inBoxItem := inBoxCursor:Entry(); while inBoxItem do begin if EntryValid(inBoxItem) and (inBoxItem.state = 'received or inBoxItem.state = 'read) then begin local inBoxItemTitle := TransportNotify(kEETransferTransportSymbol, 'GetItemTitle, [inBoxItem]); GetRoot():Notify(kNotifyAlert, EnsureInternal(kAppName), EnsureInternal(ParamStr("RHandleReceivedFilesS: An item called R^0S has been received in the InBox", [ inBoxItemTitle ]))); // When you have processe the inBoxItem, you can remove it by doing the // following instruction: // ioBox:ItemCompleted(inBoxItem, nil); end; inBoxItem := inBoxCursor:Next(); end; end login: "EETransfer" // Put your login here. password: "Easter-eggs" // Put your password here. phoneNumber: "01 23 45 67 89" // Put the server phone number here. viewSetupFormScript: func() begin inherited:?viewSetupFormScript(); // Tell EETransfer that this application is its current client. call SetEETransferClient with (kAppSymbol); end Add a "Send" button to the base view * Draw a protoTextButton as a child of the protoApp. * Set the following slots to the following values: text: "Send" buttonClickScript: func() begin // The kQuietSendAllFunc is provided by the NTK Platform file. // Its selects all the pending items in the OutBox and tells // EETransfer to send them. call kQuietSendAllFunc with (kEETransferTransportSymbol); end Add a "Receive" button to the base view * Draw a protoTextButton as a child of the protoApp. * Set the following slots to the following values: text: "Receive" buttonClickScript: func() begin // Tells EETransfer that the user wants to receive all the // files available on the server. TransportNotify(kEETransferTransportSymbol, 'ReceiveRequest, [{cause: 'user}]); end Add InstallScript and RemoveScript * Create a text file and add the following to it: InstallScript := func(partFrame) begin // Register the application as an EETransfer client. call RegEETransferClient with (kAppSymbol); end; RemoveScript := func(partFrame) begin call UnRegEETransferClient with (kAppSymbol); end; * Save the text file and add it to the project.