fixed some warnings
code style of MMediaFilesManager.* git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20703 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
309289eb87
commit
88ec4b1dbe
@ -11,6 +11,7 @@ namespace BPrivate { namespace media {
|
||||
|
||||
class ChunkProvider {
|
||||
public:
|
||||
virtual ~ChunkProvider() {};
|
||||
virtual status_t GetNextChunk(const void **chunkBuffer, size_t *chunkSize,
|
||||
media_header *mediaHeader) = 0;
|
||||
};
|
||||
|
@ -143,7 +143,7 @@ PluginManager::~PluginManager()
|
||||
{
|
||||
CALLED();
|
||||
while (!fPluginList->IsEmpty()) {
|
||||
plugin_info *info;
|
||||
plugin_info *info = NULL;
|
||||
fPluginList->Get(fPluginList->CountItems() - 1, &info);
|
||||
printf("PluginManager: Error, unloading PlugIn %s with usecount %d\n", info->name, info->usecount);
|
||||
delete info->plugin;
|
||||
|
@ -36,16 +36,16 @@ int32
|
||||
MMediaFilesManager::ReadPascalString(BFile &file, char **str)
|
||||
{
|
||||
uint32 len;
|
||||
*str=NULL;
|
||||
*str = NULL;
|
||||
if (file.Read(&len, 4) < 4)
|
||||
return -1;
|
||||
return -1;
|
||||
if (len == 0)
|
||||
return 0;
|
||||
return 0;
|
||||
*str = (char *)malloc(len);
|
||||
if (file.Read(*str, len) < (int32)len) {
|
||||
free(*str);
|
||||
*str = NULL;
|
||||
return -1;
|
||||
free(*str);
|
||||
*str = NULL;
|
||||
return -1;
|
||||
}
|
||||
return (int32)len;
|
||||
}
|
||||
@ -55,15 +55,15 @@ int32
|
||||
MMediaFilesManager::WritePascalString(BFile &file, const char *str)
|
||||
{
|
||||
|
||||
if(str == NULL)
|
||||
return -1;
|
||||
if (str == NULL)
|
||||
return -1;
|
||||
uint32 len = strlen(str) + 1;
|
||||
if (file.Write(&len, 4) < 4)
|
||||
return -1;
|
||||
return -1;
|
||||
if (len == 0)
|
||||
return 0;
|
||||
return 0;
|
||||
if (file.Write(str, len) < (int32)len) {
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
return (int32)len;
|
||||
}
|
||||
@ -76,7 +76,7 @@ MMediaFilesManager::LoadState()
|
||||
CALLED();
|
||||
status_t err = B_OK;
|
||||
BPath path;
|
||||
if((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path))!=B_OK)
|
||||
if ((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK)
|
||||
return err;
|
||||
|
||||
path.Append("Media/MMediaFilesManager");
|
||||
@ -84,8 +84,8 @@ MMediaFilesManager::LoadState()
|
||||
BFile file(path.Path(), B_READ_ONLY);
|
||||
|
||||
uint32 category_count;
|
||||
if (file.Read(header, sizeof(uint32)*3) < (int32)sizeof(uint32)*3) {
|
||||
header[0] = 0xac00150c;
|
||||
if (file.Read(header, sizeof(uint32)*3) < (int32)sizeof(uint32)*3) {
|
||||
header[0] = 0xac00150c;
|
||||
header[1] = 0x18723462;
|
||||
header[2] = 0x00000001;
|
||||
return B_ERROR;
|
||||
@ -106,30 +106,30 @@ MMediaFilesManager::LoadState()
|
||||
break;
|
||||
TRACE("%s {\n", str);
|
||||
do {
|
||||
len = ReadPascalString(file, &key);
|
||||
if (len < 0)
|
||||
return B_ERROR;
|
||||
if (len == 0)
|
||||
break;
|
||||
len = ReadPascalString(file, &val);
|
||||
if (len == 1) {
|
||||
free(val);
|
||||
val = strdup("(null)");
|
||||
}
|
||||
/*if (file.Read(&vol, sizeof(uint32)) < (int32)sizeof(uint32))
|
||||
return B_ERROR;*/
|
||||
//TRACE(" %s: %s, volume: %f\n", key, val, *(float *)&vol);
|
||||
len = ReadPascalString(file, &key);
|
||||
if (len < 0)
|
||||
return B_ERROR;
|
||||
if (len == 0)
|
||||
break;
|
||||
len = ReadPascalString(file, &val);
|
||||
if (len == 1) {
|
||||
free(val);
|
||||
val = strdup("(null)");
|
||||
}
|
||||
/*if (file.Read(&vol, sizeof(uint32)) < (int32)sizeof(uint32))
|
||||
return B_ERROR;*/
|
||||
//TRACE(" %s: %s, volume: %f\n", key, val, *(float *)&vol);
|
||||
|
||||
entry_ref ref;
|
||||
if(len>1) {
|
||||
BEntry entry(val);
|
||||
if(entry.Exists())
|
||||
entry.GetRef(&ref);
|
||||
}
|
||||
SetRefFor(str, key, ref, false);
|
||||
entry_ref ref;
|
||||
if (len > 1) {
|
||||
BEntry entry(val);
|
||||
if (entry.Exists())
|
||||
entry.GetRef(&ref);
|
||||
}
|
||||
SetRefFor(str, key, ref, false);
|
||||
|
||||
free(key);
|
||||
free(val);
|
||||
free(key);
|
||||
free(val);
|
||||
} while (true);
|
||||
TRACE("}\n");
|
||||
free(str);
|
||||
@ -145,7 +145,7 @@ MMediaFilesManager::SaveState()
|
||||
CALLED();
|
||||
status_t err = B_OK;
|
||||
BPath path;
|
||||
if((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path))!=B_OK)
|
||||
if ((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK)
|
||||
return err;
|
||||
|
||||
path.Append("Media/MMediaFilesManager");
|
||||
@ -156,14 +156,14 @@ MMediaFilesManager::SaveState()
|
||||
if (file.Write(header, sizeof(uint32)*3) < (int32)sizeof(uint32)*3)
|
||||
return B_ERROR;
|
||||
uint32 category_count = fRegistryMap->CountItems();
|
||||
if (file.Write(&category_count, sizeof(uint32)) < (int32)sizeof(uint32))
|
||||
if (file.Write(&category_count, sizeof(uint32)) < (int32)sizeof(uint32))
|
||||
return B_ERROR;
|
||||
|
||||
BString *type;
|
||||
BString *type = NULL;
|
||||
Map<BString, entry_ref> *map;
|
||||
BString *item;
|
||||
BString *item = NULL;
|
||||
entry_ref *ref;
|
||||
for (fRegistryMap->Rewind(); fRegistryMap->GetNext(&map); ) {
|
||||
for (fRegistryMap->Rewind(); fRegistryMap->GetNext(&map);) {
|
||||
fRegistryMap->GetCurrentKey(&type);
|
||||
|
||||
WritePascalString(file, type->String());
|
||||
@ -194,11 +194,11 @@ MMediaFilesManager::Dump()
|
||||
/* for each type, the registry map contains a map of item/entry_ref
|
||||
*/
|
||||
printf("MMediaFilesManager: registry map follows\n");
|
||||
BString *type;
|
||||
BString *type = NULL;
|
||||
Map<BString, entry_ref> *map;
|
||||
BString *item;
|
||||
BString *item = NULL;
|
||||
entry_ref *ref;
|
||||
for (fRegistryMap->Rewind(); fRegistryMap->GetNext(&map); ) {
|
||||
for (fRegistryMap->Rewind(); fRegistryMap->GetNext(&map);) {
|
||||
fRegistryMap->GetCurrentKey(&type);
|
||||
|
||||
for (map->Rewind(); map->GetNext(&ref);) {
|
||||
@ -218,17 +218,17 @@ status_t
|
||||
MMediaFilesManager::RewindTypes(BString ***types, int32 *count)
|
||||
{
|
||||
CALLED();
|
||||
if(types==NULL || count == NULL)
|
||||
if (types == NULL || count == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
Map<BString, entry_ref> *map;
|
||||
BString *type;
|
||||
BString *type = NULL;
|
||||
|
||||
*count = fRegistryMap->CountItems();
|
||||
*types = new BString*[*count];
|
||||
int32 i=0;
|
||||
int32 i = 0;
|
||||
|
||||
for (fRegistryMap->Rewind(); i<*count && fRegistryMap->GetNext(&map); i++) {
|
||||
for (fRegistryMap->Rewind(); i < *count && fRegistryMap->GetNext(&map); i++) {
|
||||
fRegistryMap->GetCurrentKey(&type);
|
||||
(*types)[i] = type;
|
||||
}
|
||||
@ -241,12 +241,12 @@ status_t
|
||||
MMediaFilesManager::RewindRefs(const char* type, BString ***items, int32 *count)
|
||||
{
|
||||
CALLED();
|
||||
if(type == NULL || items==NULL || count == NULL)
|
||||
if (type == NULL || items == NULL || count == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
Map<BString, entry_ref> *map;
|
||||
Map<BString, entry_ref> *map = NULL;
|
||||
entry_ref *ref;
|
||||
BString *item;
|
||||
BString *item = NULL;
|
||||
|
||||
*count = 0;
|
||||
*items = NULL;
|
||||
@ -256,9 +256,9 @@ MMediaFilesManager::RewindRefs(const char* type, BString ***items, int32 *count)
|
||||
|
||||
*count = map->CountItems();
|
||||
*items = new BString*[*count];
|
||||
int32 i=0;
|
||||
int32 i = 0;
|
||||
|
||||
for (map->Rewind(); i<*count && map->GetNext(&ref); i++) {
|
||||
for (map->Rewind(); i < *count && map->GetNext(&ref); i++) {
|
||||
map->GetCurrentKey(&item);
|
||||
(*items)[i] = item;
|
||||
}
|
||||
@ -269,15 +269,15 @@ MMediaFilesManager::RewindRefs(const char* type, BString ***items, int32 *count)
|
||||
|
||||
status_t
|
||||
MMediaFilesManager::GetRefFor(const char *type,
|
||||
const char *item,
|
||||
entry_ref **out_ref)
|
||||
const char *item,
|
||||
entry_ref **out_ref)
|
||||
{
|
||||
CALLED();
|
||||
Map <BString, entry_ref> *map;
|
||||
if(!fRegistryMap->Get(BString(type), &map))
|
||||
Map <BString, entry_ref> *map = NULL;
|
||||
if (!fRegistryMap->Get(BString(type), &map))
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
if(!map->Get(BString(item), out_ref))
|
||||
if (!map->Get(BString(item), out_ref))
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
return B_OK;
|
||||
@ -286,8 +286,8 @@ MMediaFilesManager::GetRefFor(const char *type,
|
||||
|
||||
status_t
|
||||
MMediaFilesManager::SetRefFor(const char *type,
|
||||
const char *item,
|
||||
const entry_ref &ref, bool save)
|
||||
const char *item,
|
||||
const entry_ref &ref, bool save)
|
||||
{
|
||||
CALLED();
|
||||
TRACE("MMediaFilesManager::SetRefFor %s %s\n", type, item);
|
||||
@ -296,16 +296,16 @@ MMediaFilesManager::SetRefFor(const char *type,
|
||||
itemString.Truncate(B_MEDIA_NAME_LENGTH);
|
||||
BString typeString(type);
|
||||
Map <BString, entry_ref> *map;
|
||||
if(!fRegistryMap->Get(typeString, &map)) {
|
||||
if (!fRegistryMap->Get(typeString, &map)) {
|
||||
map = new Map<BString, entry_ref>;
|
||||
fRegistryMap->Insert(typeString, *map);
|
||||
fRegistryMap->Get(typeString, &map);
|
||||
}
|
||||
|
||||
if(map->Has(itemString))
|
||||
if (map->Has(itemString))
|
||||
map->Remove(itemString);
|
||||
map->Insert(itemString, ref);
|
||||
if(save)
|
||||
if (save)
|
||||
LaunchTimer();
|
||||
|
||||
return B_OK;
|
||||
@ -314,14 +314,14 @@ MMediaFilesManager::SetRefFor(const char *type,
|
||||
|
||||
status_t
|
||||
MMediaFilesManager::RemoveRefFor(const char *type,
|
||||
const char *item,
|
||||
const entry_ref &ref)
|
||||
const char *item,
|
||||
const entry_ref &ref)
|
||||
{
|
||||
CALLED();
|
||||
BString itemString(item);
|
||||
BString typeString(type);
|
||||
Map <BString, entry_ref> *map;
|
||||
if(fRegistryMap->Get(typeString, &map)) {
|
||||
if (fRegistryMap->Get(typeString, &map)) {
|
||||
map->Remove(itemString);
|
||||
map->Insert(itemString, *(new entry_ref));
|
||||
LaunchTimer();
|
||||
@ -332,13 +332,13 @@ MMediaFilesManager::RemoveRefFor(const char *type,
|
||||
|
||||
status_t
|
||||
MMediaFilesManager::RemoveItem(const char *type,
|
||||
const char *item)
|
||||
const char *item)
|
||||
{
|
||||
CALLED();
|
||||
BString itemString(item);
|
||||
BString typeString(type);
|
||||
Map <BString, entry_ref> *map;
|
||||
if(fRegistryMap->Get(typeString, &map)) {
|
||||
if (fRegistryMap->Get(typeString, &map)) {
|
||||
map->Remove(itemString);
|
||||
LaunchTimer();
|
||||
}
|
||||
@ -349,9 +349,9 @@ MMediaFilesManager::RemoveItem(const char *type,
|
||||
void
|
||||
MMediaFilesManager::LaunchTimer()
|
||||
{
|
||||
if(!fRunner)
|
||||
if (!fRunner)
|
||||
fRunner = new BMessageRunner(be_app,
|
||||
new BMessage(MMEDIAFILESMANAGER_SAVE_TIMER), 3 * 1000000, 1);
|
||||
new BMessage(MMEDIAFILESMANAGER_SAVE_TIMER), 3 * 1000000LL, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,52 +15,52 @@
|
||||
|
||||
class MMediaFilesManager
|
||||
{
|
||||
public:
|
||||
MMediaFilesManager();
|
||||
~MMediaFilesManager();
|
||||
public:
|
||||
MMediaFilesManager();
|
||||
~MMediaFilesManager();
|
||||
|
||||
status_t LoadState();
|
||||
status_t SaveState();
|
||||
status_t LoadState();
|
||||
status_t SaveState();
|
||||
|
||||
void Dump();
|
||||
void Dump();
|
||||
|
||||
status_t RewindTypes(
|
||||
BString ***types,
|
||||
int32 *count);
|
||||
status_t RewindRefs(
|
||||
const char * type,
|
||||
BString ***items,
|
||||
int32 *count);
|
||||
status_t GetRefFor(
|
||||
const char * type,
|
||||
const char * item,
|
||||
entry_ref ** out_ref);
|
||||
status_t SetRefFor(
|
||||
const char * type,
|
||||
const char * item,
|
||||
const entry_ref & ref,
|
||||
bool save = true);
|
||||
status_t RemoveRefFor( // This might better be called "ClearRefFor"
|
||||
const char * type, // but it's too late now...
|
||||
const char * item,
|
||||
const entry_ref & ref);
|
||||
status_t RewindTypes(
|
||||
BString ***types,
|
||||
int32 *count);
|
||||
status_t RewindRefs(
|
||||
const char * type,
|
||||
BString ***items,
|
||||
int32 *count);
|
||||
status_t GetRefFor(
|
||||
const char * type,
|
||||
const char * item,
|
||||
entry_ref ** out_ref);
|
||||
status_t SetRefFor(
|
||||
const char * type,
|
||||
const char * item,
|
||||
const entry_ref & ref,
|
||||
bool save = true);
|
||||
status_t RemoveRefFor(
|
||||
const char * type,
|
||||
const char * item,
|
||||
const entry_ref & ref);
|
||||
|
||||
status_t RemoveItem( // new in 4.1, removes the whole item.
|
||||
const char * type,
|
||||
const char * item);
|
||||
status_t RemoveItem(
|
||||
const char * type,
|
||||
const char * item);
|
||||
|
||||
void TimerMessage();
|
||||
void TimerMessage();
|
||||
|
||||
private:
|
||||
static int32 ReadPascalString(BFile &file, char **str);
|
||||
static int32 WritePascalString(BFile &file, const char *str);
|
||||
void LaunchTimer();
|
||||
private:
|
||||
BLocker *fLocker;
|
||||
private:
|
||||
static int32 ReadPascalString(BFile &file, char **str);
|
||||
static int32 WritePascalString(BFile &file, const char *str);
|
||||
void LaunchTimer();
|
||||
private:
|
||||
BLocker *fLocker;
|
||||
|
||||
Map<BString, Map<BString, entry_ref> > * fRegistryMap;
|
||||
Map<BString, Map<BString, entry_ref> > * fRegistryMap;
|
||||
|
||||
uint32 header[3];
|
||||
uint32 header[3];
|
||||
|
||||
BMessageRunner *fRunner;
|
||||
BMessageRunner *fRunner;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user