Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16431 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
eb797182df
commit
91fe5e6e58
@ -542,10 +542,10 @@ BRoster::GetActiveAppInfo(app_info *info) const
|
|||||||
status_t
|
status_t
|
||||||
BRoster::FindApp(const char *mimeType, entry_ref *app) const
|
BRoster::FindApp(const char *mimeType, entry_ref *app) const
|
||||||
{
|
{
|
||||||
status_t error = (mimeType && app ? B_OK : B_BAD_VALUE);
|
if (mimeType == NULL || app == NULL)
|
||||||
if (error == B_OK)
|
return B_BAD_VALUE;
|
||||||
error = _ResolveApp(mimeType, NULL, app, NULL, NULL, NULL);
|
|
||||||
return error;
|
return _ResolveApp(mimeType, NULL, app, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindApp
|
// FindApp
|
||||||
@ -584,12 +584,11 @@ BRoster::FindApp(const char *mimeType, entry_ref *app) const
|
|||||||
status_t
|
status_t
|
||||||
BRoster::FindApp(entry_ref *ref, entry_ref *app) const
|
BRoster::FindApp(entry_ref *ref, entry_ref *app) const
|
||||||
{
|
{
|
||||||
status_t error = (ref && app ? B_OK : B_BAD_VALUE);
|
if (ref == NULL || app == NULL)
|
||||||
if (error == B_OK) {
|
return B_BAD_VALUE;
|
||||||
entry_ref _ref(*ref);
|
|
||||||
error = _ResolveApp(NULL, &_ref, app, NULL, NULL, NULL);
|
entry_ref _ref(*ref);
|
||||||
}
|
return _ResolveApp(NULL, &_ref, app, NULL, NULL, NULL);
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1894,30 +1893,33 @@ BRoster::_DumpRoster() const
|
|||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BRoster::_ResolveApp(const char *inType, entry_ref *ref,
|
BRoster::_ResolveApp(const char *inType, entry_ref *ref,
|
||||||
entry_ref *appRef, char *appSig, uint32 *appFlags,
|
entry_ref* _appRef, char* _appSig, uint32* _appFlags,
|
||||||
bool *wasDocument) const
|
bool* _wasDocument) const
|
||||||
{
|
{
|
||||||
status_t error = (inType || ref ? B_OK : B_BAD_VALUE);
|
if ((inType == NULL && ref == NULL)
|
||||||
if (error == B_OK && inType && strlen(inType) >= B_MIME_TYPE_LENGTH)
|
|| (inType != NULL && strlen(inType) >= B_MIME_TYPE_LENGTH))
|
||||||
error = B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// find the app
|
// find the app
|
||||||
BMimeType appMeta;
|
BMimeType appMeta;
|
||||||
BFile appFile;
|
BFile appFile;
|
||||||
entry_ref _appRef;
|
entry_ref appRef;
|
||||||
if (error == B_OK) {
|
status_t error;
|
||||||
if (inType)
|
|
||||||
error = _TranslateType(inType, &appMeta, &_appRef, &appFile);
|
if (inType)
|
||||||
else {
|
error = _TranslateType(inType, &appMeta, &appRef, &appFile);
|
||||||
error = _TranslateRef(ref, &appMeta, &_appRef, &appFile,
|
else {
|
||||||
wasDocument);
|
error = _TranslateRef(ref, &appMeta, &appRef, &appFile,
|
||||||
}
|
_wasDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create meta mime
|
// create meta mime
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
BPath path;
|
BPath path;
|
||||||
if (path.SetTo(&_appRef) == B_OK)
|
if (path.SetTo(&appRef) == B_OK)
|
||||||
create_app_meta_mime(path.Path(), false, true, false);
|
create_app_meta_mime(path.Path(), false, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the app hint on the type -- but only if the file has the
|
// set the app hint on the type -- but only if the file has the
|
||||||
// respective signature, otherwise unset the app hint
|
// respective signature, otherwise unset the app hint
|
||||||
BAppFileInfo appFileInfo;
|
BAppFileInfo appFileInfo;
|
||||||
@ -1926,7 +1928,7 @@ BRoster::_ResolveApp(const char *inType, entry_ref *ref,
|
|||||||
if (appFileInfo.SetTo(&appFile) == B_OK
|
if (appFileInfo.SetTo(&appFile) == B_OK
|
||||||
&& appFileInfo.GetSignature(signature) == B_OK) {
|
&& appFileInfo.GetSignature(signature) == B_OK) {
|
||||||
if (!strcasecmp(appMeta.Type(), signature))
|
if (!strcasecmp(appMeta.Type(), signature))
|
||||||
appMeta.SetAppHint(&_appRef);
|
appMeta.SetAppHint(&appRef);
|
||||||
else {
|
else {
|
||||||
appMeta.SetAppHint(NULL);
|
appMeta.SetAppHint(NULL);
|
||||||
appMeta.SetTo(signature);
|
appMeta.SetTo(signature);
|
||||||
@ -1934,30 +1936,34 @@ BRoster::_ResolveApp(const char *inType, entry_ref *ref,
|
|||||||
} else
|
} else
|
||||||
appMeta.SetAppHint(NULL);
|
appMeta.SetAppHint(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the return values
|
// set the return values
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
if (appRef)
|
if (_appRef)
|
||||||
*appRef = _appRef;
|
*_appRef = appRef;
|
||||||
if (appSig) {
|
|
||||||
|
if (_appSig) {
|
||||||
// there's no warranty, that appMeta is valid
|
// there's no warranty, that appMeta is valid
|
||||||
if (appMeta.IsValid())
|
if (appMeta.IsValid())
|
||||||
strcpy(appSig, appMeta.Type());
|
strcpy(_appSig, appMeta.Type());
|
||||||
else
|
else
|
||||||
appSig[0] = '\0';
|
_appSig[0] = '\0';
|
||||||
}
|
}
|
||||||
if (appFlags) {
|
|
||||||
|
if (_appFlags) {
|
||||||
// if an error occurs here, we don't care and just set a default
|
// if an error occurs here, we don't care and just set a default
|
||||||
// value
|
// value
|
||||||
if (appFileInfo.InitCheck() != B_OK
|
if (appFileInfo.InitCheck() != B_OK
|
||||||
|| appFileInfo.GetAppFlags(appFlags) != B_OK) {
|
|| appFileInfo.GetAppFlags(_appFlags) != B_OK) {
|
||||||
*appFlags = B_REG_DEFAULT_APP_FLAGS;
|
*_appFlags = B_REG_DEFAULT_APP_FLAGS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// unset the ref on error
|
// unset the ref on error
|
||||||
if (appRef)
|
if (_appRef)
|
||||||
*appRef = _appRef;
|
*_appRef = appRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2127,6 +2133,7 @@ BRoster::_TranslateType(const char *mimeType, BMimeType *appMeta,
|
|||||||
} else
|
} else
|
||||||
appMeta->SetAppHint(NULL); // bad app hint -- remove it
|
appMeta->SetAppHint(NULL); // bad app hint -- remove it
|
||||||
}
|
}
|
||||||
|
|
||||||
// in case there is no app hint or it is invalid, we need to query for the
|
// in case there is no app hint or it is invalid, we need to query for the
|
||||||
// app
|
// app
|
||||||
if (error == B_OK && !appFound)
|
if (error == B_OK && !appFound)
|
||||||
|
Loading…
Reference in New Issue
Block a user