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