Exemple #1
0
void
DtMail::Session::queryImplV(DtMailEnv & error,
			   const char * impl,
			   const char * capability,
			   va_list args)
{
    int slot = lookupImpl(impl);

    if (slot < 0) {
	error.setError(DTME_NoSuchImplementation);
	return;
    }

    error.clear();

    // We need to retrieve the QueryImpl entry point for the implementation.
    //
    QueryImplEntry qie;
    
    qie = (QueryImplEntry)_impls[slot].impl_meta_factory(QueryImplEntryOp);
    if (!qie) {
	error.setError(DTME_ImplFailure);
	return;
    }

    qie(*this, error, capability, args);

    return;
}
Exemple #2
0
void
DtMail::Session::setDefaultImpl(DtMailEnv & error, const char * impl)
{
    int slot = lookupImpl(impl);

    if (slot < 0) {
	error.setError(DTME_NoSuchImplementation);
	return;
    }

    MutexLock lock_scope(_obj_mutex);

    _default_impl = slot;
    error.clear();
}
Exemple #3
0
void
DtMail::Session::buildImplTable(DtMailEnv & error)
{
  error.clear();

    // Let's pick a ridiculous number of implementations.
    _impls = (Impls *)malloc(sizeof(Impls) * MaxImpls);
    _impl_names = (const char **)malloc(sizeof(char *) * (MaxImpls + 1));

    // We will simply walk through the default implementations
    // to start, adding them to the impl table.
    int tbl;
    for (tbl = 0, _num_impls = 0; initial_impls[tbl].meta_entry_point; tbl++) {
	// Get the library handle.
	DynamicLib * dl = CreatePlatformDl(initial_impls[tbl].lib_name);

	if (dl) { // We are only interested in libraries we can load.
	    _impls[_num_impls].impl_lib = dl;
	    _impls[_num_impls].impl_meta_factory =
	      (MetaImplFactory)dl->getSym(initial_impls[tbl].meta_entry_point);
	    if (_impls[_num_impls].impl_meta_factory == NULL) {
		delete dl;
		continue;
	    }
	    _impls[_num_impls].impl_name = strdup(initial_impls[tbl].impl_name);
	    _impl_names[_num_impls] = _impls[_num_impls].impl_name;
	    _num_impls += 1;
	}
    }

    _impl_names[_num_impls] = NULL;

    if (_num_impls == 0) {
	error.setError(DTME_NoImplementations);
    }
}
Exemple #4
0
//
// NEEDS TO BE DELETED .. SHOULD NO LONGER BE USED...
//
void
DtMail::Session::setError(DtMailEnv & error, const DTMailError_t minor_code)
{
  error.setError(minor_code);
  //DtMail::setError(*this, error, minor_code);
}
Exemple #5
0
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;
}