int InitializeTooltalk(void) { char * procid; Tt_status status; int fd; procid = tt_default_procid(); status = tt_ptr_error(procid); if ((status == TT_ERR_NOMP) || (status == TT_ERR_PROCID)) { /* * We need to try to establish a connection */ procid = tt_open(); status = tt_ptr_error(procid); if (status != TT_OK) { ToolTalkError("Could not connect to ToolTalk:\n%s\n", status); return (False); } tt_free(procid); /* * Determine the Tooltalk fildes. */ fd = tt_fd(); status = tt_int_error(fd); if (status != TT_OK) { ToolTalkError("Could not connect to ToolTalk:\n%s\n", status); tt_close(); ttfdG = -1; return(False); } else { ttfdG = fd; } #ifdef DtActUseXtOverSelect /* * Add the ToolTalk file descriptor to the set monitored by Xt */ XtAddInput(fd, (XtPointer)XtInputReadMask, input_handler, 0); #endif /* DtActUseXtOverSelect */ } return (True); }
DtMail::Session::Session(DtMailEnv & error, const char * app_name) : _events(16), _valid_keys(2048) { _DtMutex = MutexInit(); error.clear(); _object_signature = 0; _cur_key = 0; // Create the ToolTalk session for managing file locking, // if one doesn't exist. _tt_channel = tt_default_procid(); if (tt_pointer_error(_tt_channel) != TT_OK) { _tt_channel = ttdt_open(&_tt_fd, app_name, "SunSoft", "%I", 0); if (tt_pointer_error(_tt_channel) != TT_OK) { error.setError(DTME_TTFailure); DebugPrintf(1, "DtMail::createSession - ttdt_open returns %s\n", tt_status_message(tt_pointer_error(_tt_channel))); return; } } else { _tt_fd = tt_fd(); } // The event_fd is how we allow async behavior to occur in a // compatible way. We use a Unix domain socket as the file descriptor. // The client will watch for activity on this file descriptor, and // call our event routine when there is activity (either from XtMainLoop, // or through some other method). // pipe(_event_fd); _app_name = strdup(app_name); DtMailEnv b_error; _mail_rc = new MailRc(error, this); buildImplTable(error); if (error.isSet()) { return; } _obj_mutex = MutexInit(); // The default implementation is specified via the DEFAULT_BACKEND // variable. If this is not set in the .mailrc, then choose entry // zero. // const char * value; _mail_rc->getValue(b_error, "DEFAULT_BACKEND", &value); if (b_error.isNotSet()) { _default_impl = lookupImpl(value); if (_default_impl < 0) { _default_impl = 0; } } else { b_error.clear(); _default_impl = 0; } DtMailSigChldList = new DtVirtArray<SigChldInfo *>(8); _busy_cb = NULL; _busy_cb_data = NULL; _canAutoSave = DTM_TRUE; _object_signature = SessionSignature; return; }