1 /* 2 * Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de 3 * Copyright 2003-2004,2012, Oliver Tappe, zooey@hirschkaefer.de 4 * Distributed under the terms of the MIT License. 5 */ 6 7 #include <EditableCatalog.h> 8 9 #include <CatalogData.h> 10 #include <MutableLocaleRoster.h> 11 12 13 using BPrivate::MutableLocaleRoster; 14 15 16 namespace BPrivate { 17 EditableCatalog::EditableCatalog(const char* type, const char* signature, 18 const char* language) 19 { 20 fCatalogData = MutableLocaleRoster::Default()->CreateCatalog(type, 21 signature, language); 22 } 23 24 25 EditableCatalog::~EditableCatalog() 26 { 27 } 28 29 30 status_t 31 EditableCatalog::SetString(const char* string, const char* translated, 32 const char* context, const char* comment) 33 { 34 if (fCatalogData == NULL) 35 return B_NO_INIT; 36 37 return fCatalogData->SetString(string, translated, context, comment); 38 } 39 40 41 status_t 42 EditableCatalog::SetString(int32 id, const char* translated) 43 { 44 if (fCatalogData == NULL) 45 return B_NO_INIT; 46 47 return fCatalogData->SetString(id, translated); 48 } 49 50 51 bool 52 EditableCatalog::CanWriteData() const 53 { 54 if (fCatalogData == NULL) 55 return false; 56 57 return fCatalogData->CanWriteData(); 58 } 59 60 61 status_t 62 EditableCatalog::SetData(const char* name, BMessage* msg) 63 { 64 if (fCatalogData == NULL) 65 return B_NO_INIT; 66 67 return fCatalogData->SetData(name, msg); 68 } 69 70 71 status_t 72 EditableCatalog::SetData(uint32 id, BMessage* msg) 73 { 74 if (fCatalogData == NULL) 75 return B_NO_INIT; 76 77 return fCatalogData->SetData(id, msg); 78 } 79 80 81 status_t 82 EditableCatalog::ReadFromFile(const char* path) 83 { 84 if (fCatalogData == NULL) 85 return B_NO_INIT; 86 87 return fCatalogData->ReadFromFile(path); 88 } 89 90 91 status_t 92 EditableCatalog::ReadFromAttribute(const entry_ref& appOrAddOnRef) 93 { 94 if (fCatalogData == NULL) 95 return B_NO_INIT; 96 97 return fCatalogData->ReadFromAttribute(appOrAddOnRef); 98 } 99 100 101 status_t 102 EditableCatalog::ReadFromResource(const entry_ref& appOrAddOnRef) 103 { 104 if (fCatalogData == NULL) 105 return B_NO_INIT; 106 107 return fCatalogData->ReadFromResource(appOrAddOnRef); 108 } 109 110 111 status_t 112 EditableCatalog::WriteToFile(const char* path) 113 { 114 if (fCatalogData == NULL) 115 return B_NO_INIT; 116 117 return fCatalogData->WriteToFile(path); 118 } 119 120 121 status_t 122 EditableCatalog::WriteToAttribute(const entry_ref& appOrAddOnRef) 123 { 124 if (fCatalogData == NULL) 125 return B_NO_INIT; 126 127 return fCatalogData->WriteToAttribute(appOrAddOnRef); 128 } 129 130 131 status_t 132 EditableCatalog::WriteToResource(const entry_ref& appOrAddOnRef) 133 { 134 if (fCatalogData == NULL) 135 return B_NO_INIT; 136 137 return fCatalogData->WriteToResource(appOrAddOnRef); 138 } 139 140 141 void EditableCatalog::MakeEmpty() 142 { 143 if (fCatalogData != NULL) 144 fCatalogData->MakeEmpty(); 145 } 146 147 148 BCatalogData* 149 EditableCatalog::CatalogData() 150 { 151 return fCatalogData; 152 } 153 154 155 } // namespace BPrivate 156