Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

StrongroomCore.h

00001 /*
00002    Copyright (C) 2002 - 2003 the Strongroom project
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    @author Denis de Leeuw Duarte
00010    @author Ewald Snel
00011 */
00012 
00013 #ifndef __STRONGROOMCORE_H_
00014 #define __STRONGROOMCORE_H_
00015 
00016 #include <inttypes.h>
00017 #include <string>
00018 
00019 #include <Document.h>
00020 #include <Error.h>
00021 #include <FilePlugin.h>
00022 #include <MetadataPlugin.h>
00023 #include <SecurityPlugin.h>
00024 #include <UserPlugin.h>
00025 #include <LogPlugin.h>
00026 #include <fstream>
00027 
00028 
00029 using namespace std;
00030 
00031 enum CoreStatus
00032 {
00033     CORE_INIT_ERROR,      //Core is not runnable. Module loading failed.
00034     CORE_READY,           //Core is runnable and waiting for coreStart().
00035     CORE_RUNNING,         //Core is in operation.
00036     CORE_SHUTTING_DOWN,   //Core is busy shutting down individual modules.
00037     CORE_BROKEN,          //Core has been stopped due to an error.
00038     CORE_HALTED           //Core and modules have been stopped successfully. 
00039 };
00040 
00041 
00057 class StrongroomCore
00058 {
00059 public:
00060 
00065     StrongroomCore(string coreConfFile);
00066 
00070     ~StrongroomCore();
00071 
00077     CoreError coreStart();
00078 
00084     CoreError systemShutdown( const UserProfile &admin );
00085 
00089     void log( const string &message, int level=0 );
00090 
00098     CoreError createDocument( const UserProfile &user, const Document &document, NumID &docid );
00099 
00106     CoreError deleteDocument( const UserProfile &user, NumID docid );
00107 
00117     CoreError changeDocument( const UserProfile &user, NumID docid, NumID fileid,
00118                               string mimetype, NumID &revid );
00119 
00127     CoreError deleteRevision( const UserProfile &user, NumID docid, NumID revid );
00128 
00138     CoreError addRendition( const UserProfile &user, NumID docid, NumID revid,
00139                             NumID fileid, string mimetype );
00140 
00148     CoreError getDocumentInfo( const UserProfile &user, NumID docid, Document &document );
00149 
00157     CoreError changeDocumentInfo( const UserProfile &user, NumID docid, const Document &document );
00158 
00169     CoreError getDocument( const UserProfile &user, NumID docid, NumID revid,
00170                            string mimetype, NumID &fileid, int64_t &length );
00171 
00180     CoreError queryUpdates( const UserProfile &user, NumID first, 
00181                             int maxlen, map<NumID,NumID> &updates );
00182 
00189     CoreError getLoginChallenge( string username, string &challenge );
00190 
00199     CoreError loginUser( string username, string challenge, string response, UserProfile &user );
00200 
00210     CoreError addUser( const UserProfile &admin, const UserProfile &userProfile,
00211                        string challenge, string password, NumID &userid );
00212 
00219     CoreError deleteUser( const UserProfile &admin, NumID userid );
00220 
00228     CoreError getUserProfile( const UserProfile &admin, NumID userid, UserProfile &userProfile );
00229 
00237     CoreError changeUserProfile( const UserProfile &admin, NumID userid, const UserProfile &userProfile );
00238 
00247     CoreError setPassword( const UserProfile &user, string challenge, string oldPassword, string newPassword );
00248 
00255     CoreError clearPassword( const UserProfile &admin, NumID userid );
00256 
00263     CoreError listUsers( const UserProfile &admin, vector<NumID> &users );
00264 
00273     CoreError createNewFile( const UserProfile &user, NumID docid, NumID revid, NumID &fileid );
00274 
00280     CoreError deleteNewFile( NumID fileid );
00281 
00289     int readFromFile( NumID fileid, uint8_t *buffer, int maxlen );
00290 
00298     int writeToFile( NumID fileid, const uint8_t *buffer, int length );
00299 
00305     CoreError closeFile( NumID fileid );
00306 
00311     CoreStatus coreStatus();
00312 
00313 private:
00314     FilePlugin     * fileModule;
00315     MetadataPlugin * metadataModule;
00316     SecurityPlugin * securityModule;
00317     UserPlugin     * userModule;
00318     LogPlugin      * logModule;
00319 
00320     CoreStatus status;
00321 };
00322 
00323 
00341 Plugin *loadModule( string configname, string libname, StrongroomCore *core );
00342 
00343 #endif /*__STRONGROOMCORE_H_*/

Generated on Wed Feb 18 13:45:56 2004 for strongroom by doxygen1.2.18