comparison OrthancServer/main.cpp @ 1672:4c5a85c3ff43 db-changes

sample database plugin now working
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 Oct 2015 12:20:49 +0200
parents a412ad57f0f9
children 131136aeeaa7
comparison
equal deleted inserted replaced
1671:2f2e2ec17bc4 1672:4c5a85c3ff43
655 } 655 }
656 656
657 657
658 static bool ConfigureServerContext(IDatabaseWrapper& database, 658 static bool ConfigureServerContext(IDatabaseWrapper& database,
659 IStorageArea& storageArea, 659 IStorageArea& storageArea,
660 OrthancPlugins *plugins, 660 OrthancPlugins *plugins)
661 bool allowDatabaseUpgrade) 661 {
662 {
663 if (!UpgradeDatabase(database, storageArea, allowDatabaseUpgrade))
664 {
665 return false;
666 }
667
668 ServerContext context(database, storageArea); 662 ServerContext context(database, storageArea);
669 663
670 HttpClient::SetDefaultTimeout(Configuration::GetGlobalIntegerParameter("HttpTimeout", 0)); 664 HttpClient::SetDefaultTimeout(Configuration::GetGlobalIntegerParameter("HttpTimeout", 0));
671 context.SetCompressionEnabled(Configuration::GetGlobalBoolParameter("StorageCompression", false)); 665 context.SetCompressionEnabled(Configuration::GetGlobalBoolParameter("StorageCompression", false));
672 context.SetStoreMD5ForAttachments(Configuration::GetGlobalBoolParameter("StoreMD5ForAttachments", true)); 666 context.SetStoreMD5ForAttachments(Configuration::GetGlobalBoolParameter("StoreMD5ForAttachments", true));
709 context.ResetPlugins(); 703 context.ResetPlugins();
710 } 704 }
711 #endif 705 #endif
712 706
713 return restart; 707 return restart;
708 }
709
710
711 static bool ConfigureDatabase(IDatabaseWrapper& database,
712 IStorageArea& storageArea,
713 OrthancPlugins *plugins,
714 bool allowDatabaseUpgrade)
715 {
716 database.Open();
717
718 if (!UpgradeDatabase(database, storageArea, allowDatabaseUpgrade))
719 {
720 return false;
721 }
722
723 bool success = ConfigureServerContext(database, storageArea, plugins);
724
725 database.Close();
726
727 return success;
714 } 728 }
715 729
716 730
717 static bool ConfigurePlugins(int argc, 731 static bool ConfigurePlugins(int argc,
718 char* argv[], 732 char* argv[],
749 } 763 }
750 764
751 assert(database != NULL); 765 assert(database != NULL);
752 assert(storage.get() != NULL); 766 assert(storage.get() != NULL);
753 767
754 return ConfigureServerContext(*database, *storage, &plugins, allowDatabaseUpgrade); 768 return ConfigureDatabase(*database, *storage, &plugins, allowDatabaseUpgrade);
755 769
756 #elif ORTHANC_PLUGINS_ENABLED == 0 770 #elif ORTHANC_PLUGINS_ENABLED == 0
757 // The plugins are disabled 771 // The plugins are disabled
758 databasePtr.reset(Configuration::CreateDatabaseWrapper()); 772 databasePtr.reset(Configuration::CreateDatabaseWrapper());
759 storage.reset(Configuration::CreateStorageArea()); 773 storage.reset(Configuration::CreateStorageArea());
760 774
761 return ConfigureServerContext(*databasePtr, *storage, NULL, allowDatabaseUpgrade); 775 return ConfigureDatabase(*databasePtr, *storage, NULL, allowDatabaseUpgrade);
762 776
763 #else 777 #else
764 # error The macro ORTHANC_PLUGINS_ENABLED must be set to 0 or 1 778 # error The macro ORTHANC_PLUGINS_ENABLED must be set to 0 or 1
765 #endif 779 #endif
766 } 780 }