* Improved BMimeType::GetSupportingApps(): no longer uses the provided message to
send the request, and it now checks if the object is valid. * Fixed building supporting apps table: now all types are converted to lower case, so that it works reliable now. This fixes bug #278. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16987 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -669,27 +669,24 @@ BMimeType::GetLongDescription(char *description) const
|
|||||||
status_t
|
status_t
|
||||||
BMimeType::GetSupportingApps(BMessage *signatures) const
|
BMimeType::GetSupportingApps(BMessage *signatures) const
|
||||||
{
|
{
|
||||||
status_t err = signatures ? B_OK : B_BAD_VALUE;
|
if (signatures == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
BMessage &msg = *signatures;
|
BMessage msg(B_REG_MIME_GET_SUPPORTING_APPS);
|
||||||
BMessage &reply = *signatures;
|
|
||||||
status_t result;
|
status_t result;
|
||||||
|
|
||||||
// Build and send the message, read the reply
|
status_t err = InitCheck();
|
||||||
if (!err)
|
|
||||||
msg.what = B_REG_MIME_GET_SUPPORTING_APPS;
|
|
||||||
if (!err)
|
if (!err)
|
||||||
err = msg.AddString("type", Type());
|
err = msg.AddString("type", Type());
|
||||||
if (!err)
|
if (!err)
|
||||||
err = BRoster::Private().SendTo(&msg, &reply, true);
|
err = BRoster::Private().SendTo(&msg, signatures, true);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.what == B_REG_RESULT ? (status_t)B_OK : (status_t)B_BAD_REPLY;
|
err = signatures->what == B_REG_RESULT ? (status_t)B_OK : (status_t)B_BAD_REPLY;
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.FindInt32("result", &result);
|
err = signatures->FindInt32("result", &result);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = result;
|
err = result;
|
||||||
// if (!err)
|
|
||||||
// err = reply.FindMessage("signatures", signatures);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,24 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2002-2006, Haiku.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//---------------------------------------------------------------------
|
*
|
||||||
/*!
|
* Authors:
|
||||||
\file SupportingApps.cpp
|
* Tyler Dauwalder
|
||||||
SupportingApps class implementation
|
* Ingo Weinhold, [email protected]
|
||||||
*/
|
* Axel Dörfler, [email protected]
|
||||||
|
*/
|
||||||
|
|
||||||
#include "mime/SupportingApps.h"
|
|
||||||
|
#include <mime/SupportingApps.h>
|
||||||
|
#include <mime/database_support.h>
|
||||||
|
|
||||||
|
#include <storage_support.h>
|
||||||
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <mime/database_support.h>
|
|
||||||
#include <MimeType.h>
|
#include <MimeType.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <storage_support.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -57,9 +61,9 @@ SupportingApps::GetSupportingApps(const char *type, BMessage *apps)
|
|||||||
{
|
{
|
||||||
status_t err = type && apps ? B_OK : B_BAD_VALUE;
|
status_t err = type && apps ? B_OK : B_BAD_VALUE;
|
||||||
// See if we need to do our initial build still
|
// See if we need to do our initial build still
|
||||||
if (!err && !fHaveDoneFullBuild) {
|
if (!err && !fHaveDoneFullBuild)
|
||||||
err = BuildSupportingAppsTable();
|
err = BuildSupportingAppsTable();
|
||||||
}
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
// Clear the message, as we're just going to add to it
|
// Clear the message, as we're just going to add to it
|
||||||
apps->MakeEmpty();
|
apps->MakeEmpty();
|
||||||
@@ -164,9 +168,8 @@ SupportingApps::SetSupportedTypes(const char *app, const BMessage *types, bool f
|
|||||||
// each type.
|
// each type.
|
||||||
newTypes.clear();
|
newTypes.clear();
|
||||||
const char *type;
|
const char *type;
|
||||||
for (int32 i = 0;
|
for (int32 i = 0; types->FindString(kTypesField, i, &type) == B_OK;
|
||||||
types->FindString(kTypesField, i, &type) == B_OK;
|
i++) {
|
||||||
i++) {
|
|
||||||
newTypes.insert(type);
|
newTypes.insert(type);
|
||||||
AddSupportingApp(type, app);
|
AddSupportingApp(type, app);
|
||||||
}
|
}
|
||||||
@@ -174,15 +177,11 @@ SupportingApps::SetSupportedTypes(const char *app, const BMessage *types, bool f
|
|||||||
// Update the list of stranded types by removing any types that are newly
|
// Update the list of stranded types by removing any types that are newly
|
||||||
// re-supported and adding any types that are newly un-supported
|
// re-supported and adding any types that are newly un-supported
|
||||||
for (std::set<std::string>::const_iterator i = newTypes.begin();
|
for (std::set<std::string>::const_iterator i = newTypes.begin();
|
||||||
i != newTypes.end();
|
i != newTypes.end(); i++) {
|
||||||
i++)
|
|
||||||
{
|
|
||||||
strandedTypes.erase(*i);
|
strandedTypes.erase(*i);
|
||||||
}
|
}
|
||||||
for (std::set<std::string>::const_iterator i = oldTypes.begin();
|
for (std::set<std::string>::const_iterator i = oldTypes.begin();
|
||||||
i != oldTypes.end();
|
i != oldTypes.end(); i++) {
|
||||||
i++)
|
|
||||||
{
|
|
||||||
if (newTypes.find(*i) == newTypes.end())
|
if (newTypes.find(*i) == newTypes.end())
|
||||||
strandedTypes.insert(*i);
|
strandedTypes.insert(*i);
|
||||||
}
|
}
|
||||||
@@ -192,9 +191,7 @@ SupportingApps::SetSupportedTypes(const char *app, const BMessage *types, bool f
|
|||||||
// stranded types.
|
// stranded types.
|
||||||
if (fullSync) {
|
if (fullSync) {
|
||||||
for (std::set<std::string>::const_iterator i = strandedTypes.begin();
|
for (std::set<std::string>::const_iterator i = strandedTypes.begin();
|
||||||
i != strandedTypes.end();
|
i != strandedTypes.end(); i++) {
|
||||||
i++)
|
|
||||||
{
|
|
||||||
RemoveSupportingApp((*i).c_str(), app);
|
RemoveSupportingApp((*i).c_str(), app);
|
||||||
}
|
}
|
||||||
strandedTypes.clear();
|
strandedTypes.clear();
|
||||||
@@ -203,7 +200,7 @@ SupportingApps::SetSupportedTypes(const char *app, const BMessage *types, bool f
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteSupportedTypes
|
|
||||||
/*! \brief Clears the given application's supported types list and optionally
|
/*! \brief Clears the given application's supported types list and optionally
|
||||||
removes the application from each of said types' supporting apps list.
|
removes the application from each of said types' supporting apps list.
|
||||||
\param app The application whose supported types you are clearing
|
\param app The application whose supported types you are clearing
|
||||||
@@ -296,11 +293,13 @@ SupportingApps::BuildSupportingAppsTable()
|
|||||||
// Iterate through the supported types, adding them to the list of
|
// Iterate through the supported types, adding them to the list of
|
||||||
// supported types for the application and adding the application's
|
// supported types for the application and adding the application's
|
||||||
// signature to the list of supporting apps for each type
|
// signature to the list of supporting apps for each type
|
||||||
const char *type;
|
BString type;
|
||||||
std::set<std::string> &supportedTypes = fSupportedTypes[appName];
|
std::set<std::string> &supportedTypes = fSupportedTypes[appName];
|
||||||
for (int i = 0; msg.FindString(kTypesField, i, &type) == B_OK; i++) {
|
for (int i = 0; msg.FindString(kTypesField, i, &type) == B_OK; i++) {
|
||||||
supportedTypes.insert(type);
|
type.ToLower();
|
||||||
AddSupportingApp(type, appSig);
|
// MIME types are case insensitive, so we lowercase everything
|
||||||
|
supportedTypes.insert(type.String());
|
||||||
|
AddSupportingApp(type.String(), appSig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user