bool MapiProfiles::init() { if (m_initialised) { return true; } QString profilePath(QDir::home().path()); profilePath.append(QLatin1String("/.openchange/")); QString profileFile(profilePath); profileFile.append(QString::fromLatin1("profiles.ldb")); // Check if the store exists. QDir path(profilePath); if (!path.exists()) { if (path.mkpath(profilePath)) { error() << "cannot make profile path:" << profilePath; return false; } } if (!QFile::exists(profileFile)) { if (MAPI_E_SUCCESS != CreateProfileStore(profileFile.toUtf8(), mapi_profile_get_ldif_path())) { error() << "cannot create profile store:" << profileFile << mapiError(); return false; } } if (MAPI_E_SUCCESS != MAPIInitialize(&m_context, profileFile.toLatin1())) { error() << "cannot init profile store:" << profileFile << mapiError(); return false; } m_initialised = true; return true; }
static bool mapiprofile_createdb(const char *profdb, const char *ldif_path) { enum MAPISTATUS retval; if (access(profdb, F_OK) == 0) { fprintf(stderr, "[ERROR] mapiprofile: %s already exists\n", profdb); return false; } retval = CreateProfileStore(profdb, ldif_path); if (retval != MAPI_E_SUCCESS) { mapi_errstr("CreateProfileStore", retval); return false; } return true; }